fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val stations = Array(N - 1, {Triple(0, 0, 0)})
    (0 until N - 1).map{val (C, S, F) = readInputLine().split(" ").map{it.toInt()}; stations[it] = Triple(C, S, F)}

    for (i in 0 until N) {
        var t = 0
        for (j in i until N - 1) {
            if (t < stations[j].second) {
                t = stations[j].second
            } else if (t % stations[j].third != 0) {
                t += stations[j].third - t % stations[j].third
            }
            
            t += stations[j].first
        }
        println(t)
    }
}

fun readInputLine(): String {
    return readLine()!!
}
