# coding utf-8 n = int(input()) ans = {} for i in range(n): sentence = str(input()) bunsi = int(sentence.split(" ")[0]) bunbo = int(sentence.split(" ")[1]) val = bunshi / bunbo ans[val] = sentence for k, v in sorted(ans.items(), key=lambda x: -x[0]): print(v)