a,b=list(map(int,input().split()))

c=list(eval(input()) for _ in range(a))

c.sort()

print(("".join(c)))

a,b = list(map(int,input().split()))

c = sorted(list(eval(input()) for i in range(a)))

print(("".join(c)))
a, b = list(map(int, input().split()))
c = list(eval(input()) for _ in range(a))
c.sort()
print(("".join(c)))

a, b = list(map(int, input().split()))
c = sorted(list(eval(input()) for i in range(a)))
print(("".join(c)))

-c = list(eval(input()) for _ in range(a)) -c.sort() +c = sorted(list(eval(input()) for i in range(a)))