b=[input().split() for i in range(int(input()))] for x, y in sorted(b): print(x, y)