fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return

    data class Csf(val c: Int, val s: Int, val f: Int)

    val t = 0.until(n - 1).map {
        val (c, s, f) = intList()
        Csf(c, s, f)
    }
    buildString {
        0.until(n - 1).forEach { i ->
            val c = t[i]
            var time: Long = c.s.toLong() + c.c.toLong()
            (i + 1).until(n - 1).forEach { j ->
                val c2 = t[j]
                if (time < c2.s) {
                    time = c2.s.toLong()
                } else {
                    val m = time % c2.f
                    if (m > 0) {
                        time += (c2.f - m)
                    }
                }
                time += c2.c
            }
            appendln(time)
        }
        appendln("0")
    }.let {
        println(it.trimIndent())
    }
}
