n = int(input()) l = [] for i in range(n): a, b = map(int, input().split()) l.append([a/b, a, b]) l = sorted(l)[::-1] for i in range(n): print(l[i][1], l[i][2])