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

s=[]

for _ in range(n):

	s.append(eval(input()))

s.sort()

print((''.join(s)))
n, m = map(int, input().split())

li = []

for i in range(n):

    s = input()

    li.append(s)

li.sort()

for i in li:

    print(i, end="")

n, l = list(map(int, input().split()))
s = []
for _ in range(n):
    s.append(eval(input()))
s.sort()
print(("".join(s)))

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

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