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()))

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

s.sort()

print((''.join(s)))
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()))
s = [eval(input()) for _ in range(n)]
s.sort()
print(("".join(s)))

-s = [eval(input()) for i in range(n)] +s = [eval(input()) for _ in range(n)]