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

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	long[] C, S, F;
	foreach (i; 0..N-1)
	{
		C ~= RD!long;
		S ~= RD!long;
		F ~= RD!long;
	}

	foreach (i; 0..N-1)
	{
		long t;
		foreach (j; i..N-1)
		{
			t = max(t, S[j]);
			t = (t / F[j] + (t % F[j] != 0 ? 1 : 0)) * F[j];
			t += C[j];
		}
		writeln(t);
	}
	writeln(0);

	stdout.flush();
}