n,l=map(int, input().split())

s=[list(input()) for i in range(n)]

s.sort()

for i in s:

    for j in i:

        print(j,end="")

print()

n, m = list(map(int, input().split()))



s = []



for i in range(n):

    s.append(input())



s.sort()



for i in range(n):

    print(s[i], end = '')

n, l = map(int, input().split())
s = [list(input()) for i in range(n)]
s.sort()
for i in s:
    for j in i:
        print(j, end="")
print()

n, m = list(map(int, input().split()))
s = []
for i in range(n):
    s.append(input())
s.sort()
for i in range(n):
    print(s[i], end="")

-n, l = map(int, input().split()) -s = [list(input()) for i in range(n)] +n, m = list(map(int, input().split())) +s = [] +for i in range(n): +    s.append(input()) -for i in s: -    for j in i: -        print(j, end="") -print() +for i in range(n): +    print(s[i], end="")