let () =
  let rec read () =
    let n = Scanf.scanf " %d\n" (fun x -> x) in
    if n = 0 then ()
    else
      begin
        let rec loop p_max max= function
            0 -> Printf.printf "%d %d\n" p_max max
          | i ->
             let (p,d) = Scanf.scanf " %d %d %d\n" (fun x y z->(x,y+z)) in
             if d > max then
               loop p d (i-1)
             else
               loop p_max max (i-1)
        in
        loop 0 (-1) n;
        read ()
      end
  in read ()
;;