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

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

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

print((''.join(S)))

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

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

-print(("".join(sorted([eval(input()) for _ in range(N)])))) +S = sorted([eval(input()) for _ in range(N)]) +print(("".join(S)))