n=int(input()) for i,j in sorted([input().split() for i in range(n)]): print(i,j)