N = int(input()) fracs = [tuple(map(int,input().split())) for x in range(N)] fracs.sort(key=lambda x:x[0] / x[1],reverse=True) for x,y in fracs: print(x,y)