fun main(arg: Array<String>) {
    val N = nextInt()
    val csf = Array(N - 1) { listOfInt() }
    repeat(N - 1) { n ->
        var t = 0
        for (m in n until N - 1) {
            val (c, s, f) = csf[m]
            if (t < s) t = s
            t = (t + f - 1) / f * f
            t += c
        }
        println(t)
    }
    println(0)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
