fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val stations = mutableListOf<Station>()

    repeat(n-1) {
        val (c, s, f) = readLine()!!.split(" ").map { it.toInt() }
        stations.add(Station(c, s, f))
    }

    for (i in 0 until n-1) {
        val station = stations[i]
        var time = station.s + station.c

        for (j in i+1 until n-1) {
            val nextStation = stations[j]
            time = Math.max(time, nextStation.s)

            if (time % nextStation.f == 0) {
                time += nextStation.c
            } else {
                time += (nextStation.f - (time % nextStation.f)) + nextStation.c
            }
        }

        println(time)
    }

    println(0)
}

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