#yuki750 n=int(raw_input()) ab=[] for i in xrange(n): a,b=map(int,raw_input().split()) ab.append([a,b]) res=sorted(ab,key=lambda x:(1.0*x[0]/x[1]),reverse=True) for i in xrange(n): print res[i][0],res[i][1]