fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val C = IntArray(N - 1)
    val S = IntArray(N - 1)
    val F = IntArray(N - 1)

    (0..(N-2)).forEach {
        val (c, s, f) = readLine()!!.split(" ").map { it.toInt() }
        C[it] = c
        S[it] = s
        F[it] = f
    }

    // O(N)
    (0..(N-2)).forEach {i ->
        var t = S[i]
        var station = i
        // Simulate
        // O(N)
        while (station != N - 1) {
            // Wait until the next train comes
            // Find a time quickly that meats t>=S && T%F = 0
            if (t < S[station]) {
                t = S[station]
            } else if (t.mod(F[station]) != 0) {
                // O(100)
                while (t.mod(F[station]) != 0) {
                    t++
                }
            }
            // Train leaves
            t += C[station]
            station++
            // Arrive
        }
        println(t)
    }

    // Print for Nth station
    println(0)
}
