n = int(input()) ans = [] for _ in range(n): A, B = list(map(int, input().split())) ans.append((A / B, A, B)) ans = sorted(ans, key=lambda x: -x[0]) for _, a, b in ans: print(a, b)