N=int(input())
B=sorted([input().split() for i in range(N)])
for b in B:
    print(*b)