import math





def main():

    N = int(eval(input()))

    CSF = [[int(x) for x in input().split()] for _ in range(N-1)]

    tt = []



    for j in range(N-1):

        t = CSF[j][1] + CSF[j][0]

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

            if t >= CSF[i][1]:

                n = (t - CSF[i][1]) / CSF[i][2]

                t = CSF[i][1] + CSF[i][2] * math.ceil(n)

                t += CSF[i][0]

            else:

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



        tt.append(t)



    tt.append(0)

    for t in tt:

        print(t)





main()

import math



N = int(eval(input()))

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



for i in range(N):

    t = 0



    for c, s, f in CSF[i:]:

        # 待ち時間

        if t < s:

            t = s

        else:

            t = math.ceil((t - s) / f) * f + s



        # i -> i+1に移動

        t += c



    print(t)

import math


def main():
    N = int(eval(input()))
    CSF = [[int(x) for x in input().split()] for _ in range(N - 1)]
    tt = []
    for j in range(N - 1):
        t = CSF[j][1] + CSF[j][0]
        for i in range(j + 1, N - 1):
            if t >= CSF[i][1]:
                n = (t - CSF[i][1]) / CSF[i][2]
                t = CSF[i][1] + CSF[i][2] * math.ceil(n)
                t += CSF[i][0]
            else:
                t = CSF[i][1] + CSF[i][0]
        tt.append(t)
    tt.append(0)
    for t in tt:
        print(t)


main()

import math

N = int(eval(input()))
CSF = [list(map(int, input().split())) for _ in range(N - 1)]
for i in range(N):
    t = 0
    for c, s, f in CSF[i:]:
        # 待ち時間
        if t < s:
            t = s
        else:
            t = math.ceil((t - s) / f) * f + s
        # i -> i+1に移動
        t += c
    print(t)

- -def main(): -    N = int(eval(input())) -    CSF = [[int(x) for x in input().split()] for _ in range(N - 1)] -    tt = [] -    for j in range(N - 1): -        t = CSF[j][1] + CSF[j][0] -        for i in range(j + 1, N - 1): -            if t >= CSF[i][1]: -                n = (t - CSF[i][1]) / CSF[i][2] -                t = CSF[i][1] + CSF[i][2] * math.ceil(n) -                t += CSF[i][0] -            else: -                t = CSF[i][1] + CSF[i][0] -        tt.append(t) -    tt.append(0) -    for t in tt: -        print(t) - - -main() +N = int(eval(input())) +CSF = [list(map(int, input().split())) for _ in range(N - 1)] +for i in range(N): +    t = 0 +    for c, s, f in CSF[i:]: +        # 待ち時間 +        if t < s: +            t = s +        else: +            t = math.ceil((t - s) / f) * f + s +        # i -> i+1に移動 +        t += c +    print(t)