import sys

# import collections

# import math

# import string

# import bisect

# import re

# import itertools

# import statistics



def main():

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

    c, s, f = [], [], []

    for i in range(n-1):

        ci, si, fi = (int(x) for x in sys.stdin.readline().split())

        c.append(ci); s.append(si); f.append(fi)

    

    x = []

    for i in range(n-1):

        xi = 0

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

            if s[j] >= xi: 

                xi = s[j]

                xi += c[j]

            else:

                if (xi - s[j]) % f[j] == 0:

                    xi += c[j]

                else:

                    xi += c[j] + f[j] - (xi - s[j]) % f[j]

        x.append(xi)

    x.append(0)

    for xi in x:

        print(xi)



if __name__ == "__main__":

    # execute only if run as a script

    main()



# 乗り換え時間がなく、一方通行の電車!

import sys



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

csf = list(zip(*[map(int, sys.stdin.read().split())] * 3))



def main(): 

    take_time = [None] * n



    for i in range(n):

        cur = i

        t = 0

        while cur < n - 1:

            c, s, f = csf[cur]

            if t < s:

                t = s

            else:

                t = s + f * ((t - s + f - 1) // f)

            t += c

            cur += 1

        take_time[i] = t

    return take_time

        

if __name__ == '__main__':

    ans = main()

    print(*ans, sep='\n')

import sys

# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
def main():
    n = int(sys.stdin.readline().rstrip())
    c, s, f = [], [], []
    for i in range(n - 1):
        ci, si, fi = (int(x) for x in sys.stdin.readline().split())
        c.append(ci)
        s.append(si)
        f.append(fi)
    x = []
    for i in range(n - 1):
        xi = 0
        for j in range(i, n - 1):
            if s[j] >= xi:
                xi = s[j]
                xi += c[j]
            else:
                if (xi - s[j]) % f[j] == 0:
                    xi += c[j]
                else:
                    xi += c[j] + f[j] - (xi - s[j]) % f[j]
        x.append(xi)
    x.append(0)
    for xi in x:
        print(xi)


if __name__ == "__main__":
    # execute only if run as a script
    main()
# 乗り換え時間がなく、一方通行の電車!

import sys

n = int(sys.stdin.readline().rstrip())
csf = list(zip(*[map(int, sys.stdin.read().split())] * 3))


def main():
    take_time = [None] * n
    for i in range(n):
        cur = i
        t = 0
        while cur < n - 1:
            c, s, f = csf[cur]
            if t < s:
                t = s
            else:
                t = s + f * ((t - s + f - 1) // f)
            t += c
            cur += 1
        take_time[i] = t
    return take_time


if __name__ == "__main__":
    ans = main()
    print(*ans, sep="\n")

-# import collections -# import math -# import string -# import bisect -# import re -# import itertools -# import statistics +n = int(sys.stdin.readline().rstrip()) +csf = list(zip(*[map(int, sys.stdin.read().split())] * 3)) + + -    n = int(sys.stdin.readline().rstrip()) -    c, s, f = [], [], [] -    for i in range(n - 1): -        ci, si, fi = (int(x) for x in sys.stdin.readline().split()) -        c.append(ci) -        s.append(si) -        f.append(fi) -    x = [] -    for i in range(n - 1): -        xi = 0 -        for j in range(i, n - 1): -            if s[j] >= xi: -                xi = s[j] -                xi += c[j] +    take_time = [None] * n +    for i in range(n): +        cur = i +        t = 0 +        while cur < n - 1: +            c, s, f = csf[cur] +            if t < s: +                t = s -                if (xi - s[j]) % f[j] == 0: -                    xi += c[j] -                else: -                    xi += c[j] + f[j] - (xi - s[j]) % f[j] -        x.append(xi) -    x.append(0) -    for xi in x: -        print(xi) +                t = s + f * ((t - s + f - 1) // f) +            t += c +            cur += 1 +        take_time[i] = t +    return take_time -    # execute only if run as a script -    main() -# 乗り換え時間がなく、一方通行の電車! +    ans = main() +    print(*ans, sep="\n")