let b = let R () = let t = stdin.ReadLine().Split() |> Array.map int (t.[0], t.[1]) [|'A' .. 'C'|] |> Array.map (fun c -> let (w, h) = R() (c, w, h)) b |> Array.sortWith(fun (_, h, w) (_, h', w')-> let isSameHeight = h = h' let compareByHeight = if h > h' then -1 elif h = h' then 0 else 1 let compareByWeight = if w < w' then -1 elif w = w' then 0 else 1 if isSameHeight then compareByWeight else compareByHeight) |> Array.iter(fun (c,_,_) -> printfn "%c" c)