n = int(input())
LIST=[]
for i in range(n):
LIST.append(input().split())
LIST.sort(key = lambda x:x[0])
for i in LIST:
print(*i)
biA9IGludChpbnB1dCgpKQpMSVNUPVtdCmZvciBpIGluIHJhbmdlKG4pOgogIExJU1QuYXBwZW5kKGlucHV0KCkuc3BsaXQoKSkKCkxJU1Quc29ydChrZXkgPSBsYW1iZGEgeDp4WzBdKQpmb3IgaSBpbiBMSVNUOgogIHByaW50KCppKQ==