n = int(input()) l = [] ans_d = {} for i in range(n): kid, mom = map(int, input().split()) l.append(kid/mom) ans_d[kid/mom] = str(kid) +" " + str(mom) l.sort() l.reverse() for l_i in l: print(ans_d[l_i])