// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var numStation = Number(line[0]);

	var takeTime = [];
	var firstTime = [];
	var period = [];

	for(var i = 1; i < numStation; i++){
		var tmp = line[i].split(" ");
		takeTime.push(Number(tmp[0]));
		firstTime.push(Number(tmp[1]));
		period.push(Number(tmp[2]));
		// departureTime = firstTime + period * i
		// arrivalTime = departureTime + takeTime
	}

	var minTime = [];
	for(var j = numStation - 1; j >= 0; j--){
		if(j === numStation - 1){
			minTime[j] = 0;
		} else if(j === numStation - 2){
			minTime[j] = firstTime[j] + takeTime[j];
		} else{
			var nextTime = firstTime[j] + takeTime[j];
			if(firstTime[j+1] >= nextTime){
				minTime[j] = minTime[j+1];
			} else{
				var waitTime;
				if((nextTime-firstTime[j+1])%period[j+1] === 0){
					waitTime = 0;
				} else{
					waitTime = period[j+1] - (nextTime-firstTime[j+1])%period[j+1];
				}
			minTime[j] = nextTime + waitTime + minTime[j+1] - firstTime[j+1];
			}
		}
	}

	console.log(minTime.join("\n"));

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));