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

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

x = ""

for i in range(N):

    x += S[i]

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

print(("".join(sorted([input().strip() for _ in range(N)]))))
N, L = list(map(int, input().split()))
S = sorted([input().strip() for _ in range(N)])
x = ""
for i in range(N):
    x += S[i]
print(x)

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

-S = sorted([input().strip() for _ in range(N)]) -x = "" -for i in range(N): -    x += S[i] -print(x) +print(("".join(sorted([input().strip() for _ in range(N)]))))