import java.io.InputStreamReader
import java.io.BufferedReader
import java.io.PrintWriter

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))
  val out = PrintWriter(System.`out`)

  val n = br.readLine().toInt()
  val d = (1..n-1).map {
    br.readLine().split(" ").map { it.toInt() }.toIntArray()
  }

  tailrec fun rec(acc: Int, i:Int):Int =
    if(i == n-1) acc
    else {
      val(c, s, f) = d[i]
      when {
        acc <= s -> rec(s + c, i + 1)
        (s+acc) % f == 0 -> rec(acc + c, i + 1)
        else -> rec(acc + f -((acc - s) % f) + c, i + 1)
      }
    }

  for(i in 0..d.lastIndex) {
    out.println(rec(0, i))
  }
  out.println(0)
  out.flush()
}