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

S = [str(eval(input())) for _ in range(N)]

S.sort()

print(("".join(S)))
N, L = list(map(int,input().split()))

S = sorted([eval(input()) for k in range(N)])

print(("".join(S)))

N, L = list(map(int, input().split()))
S = [str(eval(input())) for _ in range(N)]
S.sort()
print(("".join(S)))

N, L = list(map(int, input().split()))
S = sorted([eval(input()) for k in range(N)])
print(("".join(S)))

-S = [str(eval(input())) for _ in range(N)] -S.sort() +S = sorted([eval(input()) for k in range(N)])