object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val n = scanner.nextInt()

  type Station = (Int, Int, Int)

  val csf = (1 to (n-1)).map { _ =>
    (scanner.nextInt(), scanner.nextInt(), scanner.nextInt())
  }

  def go(time: Int, nexts: Seq[Station]): Int =
    nexts match {
      case Nil   => time
      case x +: xs =>
        val (c, s, f) = x
        if(time <= s) {
          go(s + c, xs)
        } else {
          val just = (time - s) % f
          val next = (f - just) % f
          go(time + next + c, xs)
        }
    }

  csf.tails.map(go(0, _)).foreach(println)
}
