from math import ceil



n = int(eval(input()))

CSF = [list(map(int,input().split())) for i in range(n-1)]



for i in range(n-1):

	time = CSF[i][1]+CSF[i][0]

	for j in range(i+1,n-1):

		if (time-CSF[j][1])%CSF[j][2] != 0 or time-CSF[j][1]<0:

			time = max(CSF[j][1],CSF[j][2]*(ceil(time/CSF[j][2])))

		time += CSF[j][0]

	print(time)

print((0))
from math import ceil

n = int(input())

cur = [0]*n

for i in range(n-1):

	c,s,f = map(int,input().split())

	for j in range(i+1):

		cur[j] = max(s,ceil(cur[j]/f)*f)+c

print(*cur,sep='\n')

from math import ceil

n = int(eval(input()))
CSF = [list(map(int, input().split())) for i in range(n - 1)]
for i in range(n - 1):
    time = CSF[i][1] + CSF[i][0]
    for j in range(i + 1, n - 1):
        if (time - CSF[j][1]) % CSF[j][2] != 0 or time - CSF[j][1] < 0:
            time = max(CSF[j][1], CSF[j][2] * (ceil(time / CSF[j][2])))
        time += CSF[j][0]
    print(time)
print((0))

from math import ceil

n = int(input())
cur = [0] * n
for i in range(n - 1):
    c, s, f = map(int, input().split())
    for j in range(i + 1):
        cur[j] = max(s, ceil(cur[j] / f) * f) + c
print(*cur, sep="\n")

-n = int(eval(input())) -CSF = [list(map(int, input().split())) for i in range(n - 1)] +n = int(input()) +cur = [0] * n -    time = CSF[i][1] + CSF[i][0] -    for j in range(i + 1, n - 1): -        if (time - CSF[j][1]) % CSF[j][2] != 0 or time - CSF[j][1] < 0: -            time = max(CSF[j][1], CSF[j][2] * (ceil(time / CSF[j][2]))) -        time += CSF[j][0] -    print(time) -print((0)) +    c, s, f = map(int, input().split()) +    for j in range(i + 1): +        cur[j] = max(s, ceil(cur[j] / f) * f) + c +print(*cur, sep="\n")