import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.array;

void main() {
    int n = readln.chomp.to!int;

    int[] c = new int[](n), s = new int[](n), f = new int[](n);

    for (int i = 0; i < n - 1; ++i) {
        auto l = readln.chomp.split.map!(to!int).array;

        c[i] = l[0];
        s[i] = l[1];
        f[i] = l[2];
    }

    for (int i = 0; i < n - 1; ++i) {
        int ans = s[i];
        for (int j = i; j < n - 1; ++j) {
            ans += c[j];

            if (j == n - 2) {
                break;
            }

            int wait;

            if (ans <= s[j + 1]) {
                ans += (s[j + 1] - ans);
            }
            else {
                if (ans % f[j + 1] != 0) {
                    wait = ((ans + f[j + 1]) / f[j + 1]) * f[j + 1] - ans;
                    ans += wait;
                }
            }
        }

        writeln(ans);
    }
    writeln(0);
    return;
}