n = int(eval(input()))



_list = []

for _ in range(n - 1):

    a, b, c = list(map(int, input().split()))

    _list.append([a, b, c])





for i in range(n - 1):

    num = i

    time = 0



    while num < n - 1:

        c, s, f = _list[num]



        if num == i:

            time += s + c

            num += 1

            continue



        while True:

            wait = s - time



            if wait >= 0:

                time += wait + c

                break



            test = (wait * -1) // f

            s += int(f * test)



            if s - time < 0:

                s += f



        num += 1



    print(time)





print((0))

n = int(eval(input()))



_list = []

for _ in range(n - 1):

    a, b, c = list(map(int, input().split()))

    _list.append([a, b, c])





for i in range(n - 1):

    num = i

    time = 0



    while num < n - 1:

        c, s, f = _list[num]



        if num == i:

            time += s + c

            num += 1

            continue



        wait = s - time



        if wait >= 0:

            time += wait + c

            num += 1

            continue



        test = (wait * -1) // f

        s += int(f * test)



        wait = s - time



        if wait >= 0:

            time += wait + c



        else:

            time += wait + c + f



        num += 1



    print(time)





print((0))

n = int(eval(input()))
_list = []
for _ in range(n - 1):
    a, b, c = list(map(int, input().split()))
    _list.append([a, b, c])
for i in range(n - 1):
    num = i
    time = 0
    while num < n - 1:
        c, s, f = _list[num]
        if num == i:
            time += s + c
            num += 1
            continue
        while True:
            wait = s - time
            if wait >= 0:
                time += wait + c
                break
            test = (wait * -1) // f
            s += int(f * test)
            if s - time < 0:
                s += f
        num += 1
    print(time)
print((0))

n = int(eval(input()))
_list = []
for _ in range(n - 1):
    a, b, c = list(map(int, input().split()))
    _list.append([a, b, c])
for i in range(n - 1):
    num = i
    time = 0
    while num < n - 1:
        c, s, f = _list[num]
        if num == i:
            time += s + c
            num += 1
            continue
        wait = s - time
        if wait >= 0:
            time += wait + c
            num += 1
            continue
        test = (wait * -1) // f
        s += int(f * test)
        wait = s - time
        if wait >= 0:
            time += wait + c
        else:
            time += wait + c + f
        num += 1
    print(time)
print((0))

-        while True: -            wait = s - time -            if wait >= 0: -                time += wait + c -                break -            test = (wait * -1) // f -            s += int(f * test) -            if s - time < 0: -                s += f +        wait = s - time +        if wait >= 0: +            time += wait + c +            num += 1 +            continue +        test = (wait * -1) // f +        s += int(f * test) +        wait = s - time +        if wait >= 0: +            time += wait + c +        else: +            time += wait + c + f