#include<cstdio>
int n,c[510],s[510],f[510],*d=c,*t=s,*g=f,i;int main(){scanf("%d",&n);for(;d<c+n-1;++d,++t,++g)scanf("%d%d%d",d,t,g);++(*g=*d=*t=0);for(;i<n;)for(int a=0,j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(a/f[j]+(a%f[j]!=0))*f[j])+c[j++];}