N = int(input()) A = [list(map(int,input().split())) for _ in range(N)] A = sorted(A,key=lambda x:x[0]/x[1],reverse=True) for a,b in A: print(a,b)