N = int(eval(input()))

C = [0] * N

S = [0] * N

F = [0] * N



for i in range(N-1):

	C[i], S[i], F[i] = list(map(int, input().split()))



def Time_spent(i,t):

	global C,S,F



	res = C[i]

	if t < S[i]:

		res += S[i]

	else: # if t >= S[i]

		for tt in range(t,t + F[i] + 1):

			if tt % F[i] == 0:

				res += tt

				break

	return res



ans = [[0 for i in range(N)] for _ in range(N)]

time = 0

for i in range(N-1):

	for j in range(i,N-1):

		if j == 0:

			ans[i][j] = Time_spent(j, 0)

		else:

			ans[i][j] = Time_spent(j, ans[i][j-1])



for i in range(N):

	print((ans[i][N-2]))
N = int(eval(input()))

C = [0] * N

S = [0] * N

F = [0] * N

for i in range(N-1):

	C[i], S[i], F[i] = list(map(int, input().split()))



def calc_time(i,t):

	global C,S,F



	res = 0

	if t < S[i]:

		res = S[i]

	elif t % F[i] == 0:

		res = t

	else:

		res = (t + F[i]) - (t % F[i])

	res += C[i]



	return res



ans = [[0 for i in range(N)] for _ in range(N)]

for i in range(N-1):

	for j in range(i,N-1):

		if j == 0:

			ans[i][j] = calc_time(j, 0)

		else:

			ans[i][j] = calc_time(j, ans[i][j-1])



for i in range(N):

	print((ans[i][N-2]))
N = int(eval(input()))
C = [0] * N
S = [0] * N
F = [0] * N
for i in range(N - 1):
    C[i], S[i], F[i] = list(map(int, input().split()))


def Time_spent(i, t):
    global C, S, F
    res = C[i]
    if t < S[i]:
        res += S[i]
    else:  # if t >= S[i]
        for tt in range(t, t + F[i] + 1):
            if tt % F[i] == 0:
                res += tt
                break
    return res


ans = [[0 for i in range(N)] for _ in range(N)]
time = 0
for i in range(N - 1):
    for j in range(i, N - 1):
        if j == 0:
            ans[i][j] = Time_spent(j, 0)
        else:
            ans[i][j] = Time_spent(j, ans[i][j - 1])
for i in range(N):
    print((ans[i][N - 2]))

N = int(eval(input()))
C = [0] * N
S = [0] * N
F = [0] * N
for i in range(N - 1):
    C[i], S[i], F[i] = list(map(int, input().split()))


def calc_time(i, t):
    global C, S, F
    res = 0
    if t < S[i]:
        res = S[i]
    elif t % F[i] == 0:
        res = t
    else:
        res = (t + F[i]) - (t % F[i])
    res += C[i]
    return res


ans = [[0 for i in range(N)] for _ in range(N)]
for i in range(N - 1):
    for j in range(i, N - 1):
        if j == 0:
            ans[i][j] = calc_time(j, 0)
        else:
            ans[i][j] = calc_time(j, ans[i][j - 1])
for i in range(N):
    print((ans[i][N - 2]))

-def Time_spent(i, t): +def calc_time(i, t): -    res = C[i] +    res = 0 -        res += S[i] -    else:  # if t >= S[i] -        for tt in range(t, t + F[i] + 1): -            if tt % F[i] == 0: -                res += tt -                break +        res = S[i] +    elif t % F[i] == 0: +        res = t +    else: +        res = (t + F[i]) - (t % F[i]) +    res += C[i] -time = 0 -            ans[i][j] = Time_spent(j, 0) +            ans[i][j] = calc_time(j, 0) -            ans[i][j] = Time_spent(j, ans[i][j - 1]) +            ans[i][j] = calc_time(j, ans[i][j - 1])