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