dic={} n = input() for i in range(n): content = input().split(" ") dic[int(content[0])/int(content[1])] = content sorted_list = sorted(dic,reverse = True) for j in sorted_list: print(j)