let N=Int(readLine()!)!
var C=[Int](),S=[Int](),F=[Int]()
for i in 1..<N{let i=readLine()!.characters.split(" ").map{Int(String($0))!};C+=[i[0]];S+=[i[1]];F+=[i[2]]}
for i in 0..<N{print((i..<N-1).reduce(0){max(S[$1],$0+(F[$1]-$0%F[$1])%F[$1])+C[$1]})}