fun main(args: Array<String>) {
    var n= readLine()
    var c= n!!.toInt()
    var array= mutableListOf<MutableList<Int>>()
    for(i in Array(c-1,{it})){
        var r= readLine()
        var array2=r!!.split(" ")
        var array3= mutableListOf<Int>()
        for(j in arrayOf(0,1,2)){
            array3.add(array2[j].toInt())
        }
        array.add(array3)
    }
    for(j in Array(c-1,{it})) {
        var a=Array(c-j-1,{it+j})
        var t = 0
        for (i in a) {
            t = time(t, array[i][0], array[i][1], array[i][2])
        }
        println(t)
    }
    println(0)
}

fun time(i:Int,c:Int,s:Int,f:Int):Int{
    var k=s
    while(k<i){
        k+=f
    }
    var t=k+c
    return t
}