N, L = map(int, input().split())

s = [input() for i in range(N)]

s.sort()

print(*s, sep="")

N, L = map(int, input().split())

s = sorted([input() for i in range(N)])

print(*s, sep="")

N, L = map(int, input().split())
s = [input() for i in range(N)]
s.sort()
print(*s, sep="")

N, L = map(int, input().split())
s = sorted([input() for i in range(N)])
print(*s, sep="")

-s = [input() for i in range(N)] -s.sort() +s = sorted([input() for i in range(N)])