for v in sorted(tuple(input().split()) for _ in range(int(input()))): print(*v)