#include <iostream>
using namespace std;
int main(){
int n;
  cin >>n;
  int c[n],s[n],f[n];
  for(int i=0;i<n-1;i++){
    cin >>c[i]>>s[i]>>f[i];
  }
  for(int i=0;i<n-1;i++){
    int time =0;
      for (int j=i;j<n-1;j++){
        int m =max(time,s[j]);
        int a = (m-1)/f[j];
        time =(a+1)*f[j]+c[j];
      }
    cout << time << endl;
  }
  cout << "0" << endl;
  return 0;
}

    