let rec(&)l w v=try(read_line()::l&w)v with _->List.map print_endline(List.sort(fun a b->(w a-w b)*2+compare a b)l);;([]&String.length)0