let n = Scanf.scanf "%d\n" (fun x -> x)

let ar =
  Array.init (n - 1) (fun _ ->
      Scanf.scanf "%d %d %d\n" (fun c s f -> (c, s, f)) )


let () =
  Array.iteri
    (fun i (c, s, f) ->
       let tmp = ref (c + s) in
       for i' = i + 1 to n - 2 do
         let nc, ns, nf = ar.(i') in
         if ns < !tmp then
           let ns' = ref ns in
           while ns' < tmp do ns' := !ns' + nf done ;
           tmp := !ns' + nc
         else tmp := ns + nc
       done ;
       Printf.printf "%d\n" !tmp)
    ar ;
  Printf.printf "%d\n" 0