from functools import cmp_to_key def cmp(a, b): if a[0]*b[1]==a[1]*b[0]: return 0 return -1 if a[0]*b[1]>a[1]*b[0] else 1 n = int(input()) AB = [list(map(int, input().split())) for _ in range(n)] AB.sort(key=cmp_to_key(cmp)) for ab in AB: print(*ab)