n = int(input()) a = [] for i in range(n): x,y = map(int, input().split()) a.append((x/y, x, y)) a.sort(reverse=True) for v,x,y in a: print(x,y)