class Problem0750: def solve(this): n = int(input()) res = [] for i in range(n): a,b = map(int,input().split()) res.append((a/b, (a,b))) res = sorted(res, reverse=True) for c in res: print("%d %d" % (c[1][0], c[1][1])) if __name__ == "__main__": problem = Problem0750() problem.solve()