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