console.log((args=>{
  const [[N],...tmp] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const t = Array(N).fill(0);
  for ( let i = 0; i < N-1; i++ ) {
    const [C,S,F] = tmp[i];
    t[i] = S + C; 
    for ( let j = 0; j < i; j++ ) {
      t[j] = Math.max(S,Math.ceil(t[j]/F)*F);
      t[j] += C;
    }
  }
  return t.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
