n = int(input()) a,b,c = [],[],[] for i in range(n): t = list(map(int, input().split())) a.append(b[0]) b.append(b[1]) c.append(b[0]/b[1]) d = sorted(c,reverse=True) for i in d: print(a[c.index(i)],b[c.index(i)])