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



n, *csf = list(map(int, sys.stdin.read().split()))

csf = list(zip(*[iter(csf)] * 3))



def main():

    for i in range(n - 1):

        t = 0

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

            if t <= s: t = s + c

            else: t = s + ((t - s + f - 1) // f) * f + c

        print(t)

    print((0))



if __name__ ==  '__main__':

    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

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


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


if __name__ == "__main__":
    main()

-n = int(sys.stdin.readline().rstrip()) -csf = list(zip(*[map(int, sys.stdin.read().split())] * 3)) +n, *csf = list(map(int, sys.stdin.read().split())) +csf = list(zip(*[iter(csf)] * 3)) -    take_time = [None] * n -    for i in range(n): -        cur = i +    for i in range(n - 1): -        while cur < n - 1: -            c, s, f = csf[cur] -            if t < s: -                t = s +        for c, s, f in csf[i:]: +            if t <= s: +                t = s + c -                t = s + f * ((t - s + f - 1) // f) -            t += c -            cur += 1 -        take_time[i] = t -    return take_time +                t = s + ((t - s + f - 1) // f) * f + c +        print(t) +    print((0)) -    ans = main() -    print(*ans, sep="\n") +    main()