n=int(input()) tmp=[] for i in range(n): a,b=map(int,input().split()) tmp.append([a/b,a,b]) tmp.sort(reverse=True) for i in range(n): print(tmp[i][1],tmp[i][2])