n = int(eval(input()))

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



for i in range(n):

    time = 0

    while True:

        if i == n-1:

            print(time)

            break

        if time < csf[i][1]:

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

        else:

            if time%csf[i][2] == 0:

                time += csf[i][0]

            else:

                time += csf[i][0] + csf[i][2] -  time%csf[i][2]

        i += 1

def solve():

    n = int(eval(input()))

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

    

    for i in range(n):

        time = 0

        while True:

            if i == n-1:

                print(time)

                break

            if time < csf[i][1]:

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

            else:

                if time%csf[i][2] == 0:

                    time += csf[i][0]

                else:

                    time += csf[i][0] + csf[i][2] -  time%csf[i][2]

            i += 1



if __name__ == "__main__":

    solve()
n = int(eval(input()))
csf = [list(map(int, input().split())) for _ in range(n - 1)]
for i in range(n):
    time = 0
    while True:
        if i == n - 1:
            print(time)
            break
        if time < csf[i][1]:
            time = csf[i][1] + csf[i][0]
        else:
            if time % csf[i][2] == 0:
                time += csf[i][0]
            else:
                time += csf[i][0] + csf[i][2] - time % csf[i][2]
        i += 1

def solve():
    n = int(eval(input()))
    csf = [list(map(int, input().split())) for _ in range(n - 1)]
    for i in range(n):
        time = 0
        while True:
            if i == n - 1:
                print(time)
                break
            if time < csf[i][1]:
                time = csf[i][1] + csf[i][0]
            else:
                if time % csf[i][2] == 0:
                    time += csf[i][0]
                else:
                    time += csf[i][0] + csf[i][2] - time % csf[i][2]
            i += 1


if __name__ == "__main__":
    solve()

-n = int(eval(input())) -csf = [list(map(int, input().split())) for _ in range(n - 1)] -for i in range(n): -    time = 0 -    while True: -        if i == n - 1: -            print(time) -            break -        if time < csf[i][1]: -            time = csf[i][1] + csf[i][0] -        else: -            if time % csf[i][2] == 0: -                time += csf[i][0] +def solve(): +    n = int(eval(input())) +    csf = [list(map(int, input().split())) for _ in range(n - 1)] +    for i in range(n): +        time = 0 +        while True: +            if i == n - 1: +                print(time) +                break +            if time < csf[i][1]: +                time = csf[i][1] + csf[i][0] -                time += csf[i][0] + csf[i][2] - time % csf[i][2] -        i += 1 +                if time % csf[i][2] == 0: +                    time += csf[i][0] +                else: +                    time += csf[i][0] + csf[i][2] - time % csf[i][2] +            i += 1 + + +if __name__ == "__main__": +    solve()