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

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



print(("".join(s)))
n,l = list(map(int, input().split()))

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

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

-s = sorted([eval(input()) for _ in range(n)]) -print(("".join(s))) +print(("".join(sorted([eval(input()) for _ in range(n)]))))