fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val cs = IntArray(n - 1)
    val ss = IntArray(n - 1)
    val fs = IntArray(n - 1)
    for (i in 0..(n - 2)) {
        val (c, s, f) = readLine()!!.split(" ").map(String::toInt)
        cs[i] = c
        ss[i] = s
        fs[i] = f
    }
    for (i in 0..(n - 1)) {
        println(solve(n, cs, ss, fs, i, 0))
    }
}

fun solve(n: Int, cs: IntArray, ss: IntArray, fs: IntArray, x: Int, t: Int): Int {
    if (x == n - 1) {
        return t
    }
    val departure = if (t < ss[x]) {
        ss[x]
    } else {
        (t + fs[x] - 1) / fs[x] * fs[x]
    }
    return solve(n, cs, ss, fs, x + 1, departure + cs[x])
}