import java.util.*

fun main(args: Array<String>){

    //var (N,M) = readLine()!!.split(" ").map{it.toInt()}
    var N = readLine()!!.toInt()
    var C = LongArray(N)
    var S = LongArray(N)
    var F = LongArray(N)

    for(i in 0 until N-1){
        var (ci,si,fi) = readLine()!!.split(" ").map{it.toLong()}
        C[i] = ci
        S[i] = si
        F[i] = fi
    }

    for(i in 0 until N-1){
        var time = 0L
        for(j in i until N-1){
            when(time <= S[j]){
                true -> time += (S[j] - time)
                false -> if(time % F[j] != 0L){
                    time += F[j] - (time % F[j])
                }
            }
            time += C[j]
        }
        println(time)
    }
    println("0")

}
