N = int(input()) C = 9*8*7*6*5 record = [] nums = [] for i in range(N): a, b = map(int, input().split()) record.append((a*C//b, i)) nums.append((a, b)) record.sort(reverse=True) for _, i in record: print(*nums[i])