import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from fractions import Fraction N = int(readline()) m = map(int,read().split()) AB = zip(m,m) AB = sorted(AB, key = lambda x : x[0] / x[1], reverse=True) print('\n'.join(' '.join(map(str,x)) for x in AB))