import sys l=i=1 S=lambda x:-int(x.split()[-1]) for d in sorted(sys.stdin,key=S): if S(d)-l:r=i i+=1;l=S(d);print r,d.strip()