n=int(input()) hoges=[list(map(int,input().split())) for i in range(n)] hoges=sorted(hoges,key=lambda x:x[0]/x[1],reverse=True) for hoge in hoges: print(hoge[0],hoge[1])