import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!int;
    int[] cs, ss, fs;
    foreach (i; 0..N-1) {
        int C, S, F;
        readf("%d %d %d\n", &C, &S, &F);
        cs ~= C;
        ss ~= S;
        fs ~= F;
    }
    foreach (i; 0..N-1) {
        long t = 0;
        foreach (j; i..N-1) {
            t = max(t, ss[j]);
            t += (fs[j] - t % fs[j]) % fs[j];
            t += cs[j];
        }
        writeln(t);
    }
    writeln(0);
}

