n, l = list(map(int, input().split()))

S = [eval(input()) for i in range(n)]

S.sort()

print(("".join(S)))
n, l = list(map(int, input().split()))

A = [eval(input()) for _ in range(n)]

A.sort()

print(("".join(A)))

n, l = list(map(int, input().split()))
S = [eval(input()) for i in range(n)]
S.sort()
print(("".join(S)))

n, l = list(map(int, input().split()))
A = [eval(input()) for _ in range(n)]
A.sort()
print(("".join(A)))

-S = [eval(input()) for i in range(n)] -S.sort() -print(("".join(S))) +A = [eval(input()) for _ in range(n)] +A.sort() +print(("".join(A)))