open System type Frac = { Numer: int; Denom: int } module Frac = let compare (x: Frac) (y: Frac) = let x' = x.Numer * y.Denom let y' = y.Numer * x.Denom compare x' y' let n = stdin.ReadLine() |> int let fracs = Array.init n (fun _ -> let A, B = let t = stdin.ReadLine().Split() |> Array.map int t.[0], t.[1] { Numer = A; Denom = B }) fracs |> Array.sortWith Frac.compare |> Array.rev |> Array.iter(fun x -> printfn "%i %i" x.Numer x.Denom)