for x in sorted([input().split()for _ in' '*int(input())]):print(*x)