n = int(input()) nums = [list(map(int, input().split())) for _ in range(n)] nums.sort(key=lambda a: a[0] / a[1], reverse=True) for a in nums: print(a[0], a[1])