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