集合の演算に関する問題です.
# ITP2_9_A
n = int(input())
A = set(map(int,input().split(" ")))
m = int(input())
B = set(map(int,input().split(" ")))
# 和集合
C = sorted(A | B)
for x in C:
print(x)
# ITP2_9_B
n = int(input())
A = set(map(int,input().split(" ")))
m = int(input())
B = set(map(int,input().split(" ")))
# 積集合
C = sorted(A & B)
for x in C:
print(x)
# ITP2_9_C
n = int(input())
A = set(map(int,input().split(" ")))
m = int(input())
B = set(map(int,input().split(" ")))
# 差集合
C = sorted(A - B)
for x in C:
print(x)
# ITP2_9_D
n = int(input())
A = set(map(int,input().split(" ")))
m = int(input())
B = set(map(int,input().split(" ")))
# 互いに素な集合 和集合から積集合を引けばいい
C = sorted((A | B) - (A & B))
for x in C:
print(x)