import sys n = int(input()) S = [] for i in range(n): s = input().split() S.append(s) S.sort() for j in range(n): print(''.join(S[j]))