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 _ in range(n)]

s.sort()

ans = ""

for i in s:

    ans += i

print(ans)
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 _ in range(n)]
s.sort()
ans = ""
for i in s:
    ans += i
print(ans)

-print(("".join(s))) +ans = "" +for i in s: +    ans += i +print(ans)