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



list = []

for _ in range(n):

    list.append(eval(input()))



list.sort()

str = ""

for s in list:

    str += s



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



list = []

for _ in range(n):

    list.append(eval(input()))



list.sort()

string = ""

for s in list:

    string += s



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

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

-str = "" +string = "" -    str += s -print(str) +    string += s +print(("".join(string)))