# No.750 Frac #1 n = int(input()) a = [] b = [] quotients = [] for i in range(n): x, y = [int(j) for j in input().split()] a.append(x) b.append(y) quotients.append(a[i] / b[i]) quotients_sorted = sorted(quotients, reverse = True) for i in range(n): idx = quotients.index(quotients_sorted[i]) print('{0} {1}'.format(a[idx], b[idx]))