n=int(input()) b=[input().split() for _ in []*n] print(*sorted(b),sep="\n")