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