n=int(input()); a=[list(map(int,input().split())) for _ in '1'*n] a=sorted(a,key=lambda x:x[0]/x[1],reverse=True) for x,y in a: print(x,y)