N = int(input()) X = [list(map(int, input().split())) for i in range(N)] X.sort(key = lambda x: x[0] / x[1], reverse = True) for i in range(N): print(*X[i])