let N=Int(readLine()!)!,a=(1..<N).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}}
for i in 0..<N{let A=(i..<N-1).map{a[$0]};print(A.reduce(0){max($1[1],($1[2]+$0-1)/$1[2]*$1[2])+$1[0]})}