n = int(input()) c = {} for i in range(n): s = input() a,b = map(int,s.split()) c[a/b] = s for k,v in sorted(c.items(),key=lambda x: -x[0]): print(v)