fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val csf = (1..n - 1).map { readLine()!!.split(" ").map { it.toLong() } }
    for(i in 0..n-2){
        var time = 0L
        for(j in i..n-2){
            val (c, s, f) = csf[j]
            val nextF = if(time%f==0L) time else time+f-time%f
            time = Math.max(s, nextF ) + c
        }
        println(time)
    }
    println(0)
}