n = int(input()) a = sorted([list(map(int, input().split())) for _ in [0]*n], key=lambda x: x[0]/x[1], reverse=True) print(*[" ".join(map(str, item)) for item in a], sep="\n")