from __future__ import print_function
from sys import stdin

def printf(str, *args):
	print(str % args, end='')

MAX = 100

def setout(A):
	count = 0
	printf("{")
	for i in range(1,MAX+1):
		if A[i] == 1:
			if count != 0:
				printf(",")
			printf("%4d"%i)
			count = 1
	printf("}\n\n")

def Union(A, B):
	temp = [0 for _ in range(0,MAX+1)]
	for i in range(1, MAX+1):
		if A[i] == 1 or B[i] == 1:
			temp[i] = 1
		else:
			temp[i] = 0
	setout(temp)

def Inter(A, B):
	temp = [0 for _ in range(0,MAX+1)]
	for i in range(1, MAX+1):
		if A[i] == 1 and B[i] == 1:
			temp[i] = 1
		else:
			temp[i] = 0
	setout(temp)

def Minus(A, B):
	temp = [0 for _ in range(0,MAX+1)]
	for i in range(1, MAX+1):
		if A[i] == 1 and B[i] == 0:
			temp[i] = 1
		else:
			temp[i] = 0
	setout(temp)

seta = [0 for _ in range(0,MAX+1)]
setb = [0 for _ in range(0,MAX+1)]

printf("\n*********************************************\n")
printf("******* This is set operation program *******\n")
printf("*********************************************\n\n")

printf(" How many elements do you want to input in Set A? : ")
a_element = int(stdin.readline())
printf(" Please input element of set A (원소의 최대값은 100이하이다.) ");
list = []
while len(list) < a_element:
	temp = stdin.readline().strip('\n').split()
	for i in temp:
		if seta[int(i)] == 1:
			printf("중복된 원소입니다.\n")
		else:
			seta[int(i)] = 1
			list += str(i)

printf(" How many elements do you want to input in Set B ? : ")
b_element = int(stdin.readline())
printf(" Please input element of set B (원소의 최대값은 100이하이다.) ");
list = []
while len(list) < b_element:
	temp = stdin.readline().strip('\n').split()
	for i in temp:
		if setb[int(i)] == 1:
			printf("중복된 원소입니다.\n")
		else:
			setb[int(i)] = 1
			list += str(i)

printf(" element of set A = \n")
setout(seta)

printf(" element of set B = \n")
setout(setb)

printf("\n")

printf(" set A union set B = \n")
Union(seta,setb)

printf(" set A intersection set B = \n")
Inter(seta,setb)

printf(" set A minus set B = \n")
Minus(seta,setb)

stdin.readline()