import sys

from collections import defaultdict, Counter

from itertools import product, groupby, count, permutations, combinations

from math import pi, sqrt, ceil, floor

from collections import deque

from bisect import bisect, bisect_left, bisect_right

from string import ascii_lowercase

from functools import lru_cache, reduce

from operator import xor

from heapq import heappush, heappop

INF = float("inf")

sys.setrecursionlimit(10**7)



# 4近傍（右, 下, 左, 上）

dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]





def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W





def main():

    N = int(eval(input()))

    C, S, F = [], [], []

    for _ in range(N - 1):

        c, s, f = list(map(int, input().split()))

        C.append(c)

        S.append(s)

        F.append(f)



    for i in range(N):

        now = 0

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

            if S[j] > now:

                now += S[j] - now



            t = ceil(now / F[j])

            now += (F[j] * t) - now

            now += C[j]

        print(now)





if __name__ == '__main__':

    main()

#!/usr/bin/python3



from collections import defaultdict, Counter

from itertools import product, groupby, count, permutations, combinations

from math import pi, sqrt

from collections import deque

from bisect import bisect, bisect_left, bisect_right

from string import ascii_lowercase

from functools import lru_cache

import sys

sys.setrecursionlimit(10000)

INF = float("inf")

YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"

dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]





def inside(y, x, H, W):

    return 0 <= y < H and 0 <= x < W





def ceil(a, b):

    return (a + b - 1) // b





def main():

    N = int(eval(input()))



    L = []

    for _ in range(N - 1):

        c, s, f = list(map(int, input().split()))

        L.append((c, s, f))



    for i in range(len(L)):

        x = 0

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

            if x <= s:

                x = s + c

            else:

                x = s + f * ceil(x - s, f) + c

        print(x)

    print((0))





if __name__ == '__main__':

    main()

import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
from heapq import heappush, heappop

INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool:
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(eval(input()))
    C, S, F = [], [], []
    for _ in range(N - 1):
        c, s, f = list(map(int, input().split()))
        C.append(c)
        S.append(s)
        F.append(f)
    for i in range(N):
        now = 0
        for j in range(i, N - 1):
            if S[j] > now:
                now += S[j] - now
            t = ceil(now / F[j])
            now += (F[j] * t) - now
            now += C[j]
        print(now)


if __name__ == "__main__":
    main()

#!/usr/bin/python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys

sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(eval(input()))
    L = []
    for _ in range(N - 1):
        c, s, f = list(map(int, input().split()))
        L.append((c, s, f))
    for i in range(len(L)):
        x = 0
        for c, s, f in L[i:]:
            if x <= s:
                x = s + c
            else:
                x = s + f * ceil(x - s, f) + c
        print(x)
    print((0))


if __name__ == "__main__":
    main()

-import sys +#!/usr/bin/python3 -from math import pi, sqrt, ceil, floor +from math import pi, sqrt -from functools import lru_cache, reduce -from operator import xor -from heapq import heappush, heappop +from functools import lru_cache +import sys +sys.setrecursionlimit(10000) -sys.setrecursionlimit(10**7) -# 4近傍（右, 下, 左, 上） -dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0] +YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" +dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] -def inside(y: int, x: int, H: int, W: int) -> bool: +def inside(y, x, H, W): + + +def ceil(a, b): +    return (a + b - 1) // b -    C, S, F = [], [], [] +    L = [] -        C.append(c) -        S.append(s) -        F.append(f) -    for i in range(N): -        now = 0 -        for j in range(i, N - 1): -            if S[j] > now: -                now += S[j] - now -            t = ceil(now / F[j]) -            now += (F[j] * t) - now -            now += C[j] -        print(now) +        L.append((c, s, f)) +    for i in range(len(L)): +        x = 0 +        for c, s, f in L[i:]: +            if x <= s: +                x = s + c +            else: +                x = s + f * ceil(x - s, f) + c +        print(x) +    print((0))