#include <iostream>
#include <string>
using namespace std;

int c[500],s[500],f[500];

int main()
{
	int n,i,now,p;
	cin >> n;
	for(i=0;i<n-1;i++)
		cin >> c[i] >> s[i] >> f[i];
	for(i=0;i<n-1;i++)
	{
		for(now=0,p=i;p<n-1;now+=c[p],p++)
			if(now<s[p]) now=s[p];
			else now=((now-s[p]-1)/f[p]+1)*f[p]+s[p];
		cout << now << "\n";
	}
	cout << "0\n";
 } 