N,L=map(int,input().split());print(*(sorted([input() for _ in range(N)])),sep='')

n,l=map(int,input().split());print(*sorted([input() for _ in range(n)]),sep='')

N, L = map(int, input().split())
print(*(sorted([input() for _ in range(N)])), sep="")

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

-N, L = map(int, input().split()) -print(*(sorted([input() for _ in range(N)])), sep="") +n, l = map(int, input().split()) +print(*sorted([input() for _ in range(n)]), sep="")