function solve() n = parse(Int, readline()) d = [] for _ in 1:n a, b = parse.(Int, split(readline())) push!(d, a//b) end sort!(d, rev=true) for x in d println(numerator(x), " ", denominator(x)) end end solve()