n=int(input()) b=[input().split()for _ in[0]*n] b.sort() for x in b:print(*x)