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

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

print(*s,sep = "")

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

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

print(("".join(s)))
n, l = map(int, input().split())
s = sorted([input() for i in range(n)])
print(*s, sep="")

n, l = list(map(int, input().split()))
s = sorted([eval(input()) for i in range(n)])
print(("".join(s)))

-n, l = map(int, input().split()) -s = sorted([input() for i in range(n)]) -print(*s, sep="") +n, l = list(map(int, input().split())) +s = sorted([eval(input()) for i in range(n)]) +print(("".join(s)))