fun main(args: Array<String>) {
    val n = readLine()!!.toInt() - 1
    if (n == 0) {
        println(0)
        return
    }

    val cs = LongArray(n)
    val ss = LongArray(n)
    val fs = LongArray(n)
    (0 until n).forEach { i ->
        val (ci, si, fi) = readLine()!!.split(" ").map { it.toLong() }
        cs[i] = ci
        ss[i] = si
        fs[i] = fi
    }

    (0 until n).forEach {
        var t: Long = 0
        (it until n).forEach { i ->
            t = maxOf(t, ss[i])

            val rem = t % fs[i]
            if (rem != 0L) t += fs[i] - rem
            
            t += cs[i]
        }
        println(t)
    }
    println(0)
}

fun maxOf(a: Long, b: Long) = if (a > b) a else b