N = int(input()) list = [] for i in range(N): n = input() m = n.split() p = [int(i) for i in m] list.append(p) a = [] A = [] for b in list: c = int(b[0]) / int(b[1]) if a: if a[-1] > c: a = a + [c] A = A + [b] else: for d in a: f = 0 if c > d: a.insert(f, c) A.insert(f, b) break else: f = f + 1 else: a = [c] A = [b] else: for g in A: j = [str(h) for h in g] print(' '.join(j))