from sys import stdin

from itertools import combinations

from math import factorial

import numpy as np

import math

import bisect



n = int(stdin.readline().rstrip())



c = [0]*n#次の駅までの時間

s = [0]*n#開通してからの時間

f = [0]*n#次の列車が来るまでの間隔



for i in range(1,n):

    c[i],s[i],f[i] = [int(x) for x in stdin.readline().rstrip().split()]



for j in range(n):

    time = 0

    fi = [0]*n

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

        if time < s[i]:

            time = s[i]

        elif time%f[i] != 0:

            time += f[i]-time%f[i]

        time += c[i]

        fi[i] = time

    print((fi[-1]))
from sys import stdin



n = int(stdin.readline().rstrip())



c = [0]*n#次の駅までの時間

s = [0]*n#開通してからの時間

f = [0]*n#次の列車が来るまでの間隔



for i in range(1,n):

    c[i],s[i],f[i] = [int(x) for x in stdin.readline().rstrip().split()]



for j in range(n):

    time = 0

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

        if time < s[i]:

            time = s[i]

        elif time%f[i] != 0:

            time += f[i]-time%f[i]

        time += c[i]

    print(time)
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
import math
import bisect

n = int(stdin.readline().rstrip())
c = [0] * n  # 次の駅までの時間
s = [0] * n  # 開通してからの時間
f = [0] * n  # 次の列車が来るまでの間隔
for i in range(1, n):
    c[i], s[i], f[i] = [int(x) for x in stdin.readline().rstrip().split()]
for j in range(n):
    time = 0
    fi = [0] * n
    for i in range(1 + j, n):
        if time < s[i]:
            time = s[i]
        elif time % f[i] != 0:
            time += f[i] - time % f[i]
        time += c[i]
        fi[i] = time
    print((fi[-1]))

from sys import stdin

n = int(stdin.readline().rstrip())
c = [0] * n  # 次の駅までの時間
s = [0] * n  # 開通してからの時間
f = [0] * n  # 次の列車が来るまでの間隔
for i in range(1, n):
    c[i], s[i], f[i] = [int(x) for x in stdin.readline().rstrip().split()]
for j in range(n):
    time = 0
    for i in range(1 + j, n):
        if time < s[i]:
            time = s[i]
        elif time % f[i] != 0:
            time += f[i] - time % f[i]
        time += c[i]
    print(time)

-from itertools import combinations -from math import factorial -import numpy as np -import math -import bisect -    fi = [0] * n -        fi[i] = time -    print((fi[-1])) +    print(time)