#38364: python解法


1257891 (1257891)


a=int(input())
f=[]
g=[]
h=[]
i=[]
for z in range(a):
    b,c,d,e=map(str,input().split())
    c=int(c)
    d=int(d)
    f.append(c)
    g.append(d)
    h.append(b)
    i.append(e)
for i in list(sorted(zip(f,g,h,i))):
    print(*i[0:3])
    print(i[-1])