N = int(eval(input()))

CSF = []

for i in range(N-1):

    CSF.append(list(map(int, input().split())))





for i in range(N-1):

    start = CSF[i][1]

    

    goal = 0

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

        start = max(CSF[cur][1], 

                    (goal//CSF[cur][2]+bool(goal%CSF[cur][2])) * CSF[cur][2])

        goal = start + CSF[cur][0]

        

    print(goal)

    

print((0))
import sys

stdin = sys.stdin



sys.setrecursionlimit(10**5) 

 

def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



n = ni()

csf = [tuple(li()) for _ in range(n-1)]



for start in range(n-1):

    time = csf[start][1]

    for station in range(start,n-1):

        if time >= csf[station][1]:

            time = (-(-time//csf[station][2]))*csf[station][2]

            time += csf[station][0]

            

        else:

            time = csf[station][1]

            time += csf[station][0]

            

    print(time)

    

print((0))
N = int(eval(input()))
CSF = []
for i in range(N - 1):
    CSF.append(list(map(int, input().split())))
for i in range(N - 1):
    start = CSF[i][1]
    goal = 0
    for cur in range(i, N - 1):
        start = max(
            CSF[cur][1], (goal // CSF[cur][2] + bool(goal % CSF[cur][2])) * CSF[cur][2]
        )
        goal = start + CSF[cur][0]
    print(goal)
print((0))

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


n = ni()
csf = [tuple(li()) for _ in range(n - 1)]
for start in range(n - 1):
    time = csf[start][1]
    for station in range(start, n - 1):
        if time >= csf[station][1]:
            time = (-(-time // csf[station][2])) * csf[station][2]
            time += csf[station][0]
        else:
            time = csf[station][1]
            time += csf[station][0]
    print(time)
print((0))

-N = int(eval(input())) -CSF = [] -for i in range(N - 1): -    CSF.append(list(map(int, input().split()))) -for i in range(N - 1): -    start = CSF[i][1] -    goal = 0 -    for cur in range(i, N - 1): -        start = max( -            CSF[cur][1], (goal // CSF[cur][2] + bool(goal % CSF[cur][2])) * CSF[cur][2] -        ) -        goal = start + CSF[cur][0] -    print(goal) +import sys + +stdin = sys.stdin +sys.setrecursionlimit(10**5) + + +def li(): +    return list(map(int, stdin.readline().split())) + + +def li_(): +    return [int(x) - 1 for x in stdin.readline().split()] + + +def lf(): +    return list(map(float, stdin.readline().split())) + + +def ls(): +    return stdin.readline().split() + + +def ns(): +    return stdin.readline().rstrip() + + +def lc(): +    return list(ns()) + + +def ni(): +    return int(stdin.readline()) + + +def nf(): +    return float(stdin.readline()) + + +n = ni() +csf = [tuple(li()) for _ in range(n - 1)] +for start in range(n - 1): +    time = csf[start][1] +    for station in range(start, n - 1): +        if time >= csf[station][1]: +            time = (-(-time // csf[station][2])) * csf[station][2] +            time += csf[station][0] +        else: +            time = csf[station][1] +            time += csf[station][0] +    print(time)