#import <stdio.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
int WAIT(int t, int s, int f){
    int r = t%f;
    return (s>=t) ? s-t : r==0 ? 0 : f-r;
}

int main(){
    int N;
    int C[600] = {0};
    int S[600] = {0};
    int F[600] = {0};
    scanf("%d",&N);
    for(int i=1;i<=N-1;i++){
        int c,s,f;
        scanf("%d %d %d",&c,&s,&f);
        C[i] = c;
        S[i] = s;
        F[i] = f;
    }
    for(int i=1;i<=N-1;i++){
        int t = S[i] + C[i];
        for(int j=i+1;j<=N-1;j++){
            t += WAIT(t,S[j],F[j]) + C[j];
        }
        printf("%d\n",t);
    }
    printf("0\n");
}
