// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint;
// }}}

void main() {
  int n = readln.chomp.to!int;
  int[] c, s, f;
  foreach (i; 0 .. n - 1) {
    int[] t = readln.chomp.split.to!(int[]);
    c ~= t[0];
    s ~= t[1];
    f ~= t[2];
  }
  foreach (i; 0 .. n - 1) {
    int res = c[i] + s[i];
    foreach (j; (i + 1) .. n - 1) {
      res = max(res, s[j]) + (max(res, s[j]) % f[j] == 0 ? 0 : (max(res, s[j]) - f[j])) + c[j];
    }
    writeln(res);
  }
  writeln(0);
}
