import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    scan(n);
    auto c = new int[](n);
    auto s = new int[](n);
    auto f = new int[](n);
    foreach (i ; 0 .. n-1) {
        int ci, si, fi;
        scan(ci,si,fi);
        c[i] = ci;
        s[i] = si;
        f[i] = fi;
    }

    foreach (i ; 0 .. n) {
        int ans;

        foreach (j ; i .. n-1) {
            if (ans < s[j]) {
                ans = s[j];
            }
            else {
                if (ans % f[j]) {
                    ans += f[j] - ans % f[j];
                }
            }
            ans += c[j];

            debug {
                writeln(j, " ", ans);
            }
        }

        writeln(ans);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}