N = int(input()) lst = [input().split() for _ in range(N)] lst.sort() print(*map(lambda x: " ".join(x), lst),sep="\n")