N = int(eval(input()))



C = []

S = []

F = []



for i in range(N - 1):

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

    C.append(c)

    S.append(s)

    F.append(f)





def next(s, t):

    # 始発

    if t < S[s]:

        t = S[s]



    # タイムラグ

    elif t % F[s]:

        t += F[s] - t % F[s]



    # 列車の移動時間

    t += C[s]



    return t





def main():

    # 出発駅

    for i in range(N - 1):

        t = next(i, 0)



        # 途中駅

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

            t = next(j, t)



        print(t)



    print((0))



    return





main()

N = int(eval(input()))



CSFn = [[int(j) for j in input().split()] for i in range(N - 1)]





def next(s):

    t = 0



    for Ci, Si, Fi in CSFn[s:]:

        # 始発

        if t < Si:

            t = Si



        # タイムラグ

        elif t % Fi:

            t += Fi - t % Fi



        # 列車の移動時間

        t += Ci



    return t





def main():

    # 出発駅

    for i in range(N - 1):

        t = next(i)

        print(t)



    print((0))



    return





main()

N = int(eval(input()))
C = []
S = []
F = []
for i in range(N - 1):
    c, s, f = list(map(int, input().split()))
    C.append(c)
    S.append(s)
    F.append(f)


def next(s, t):
    # 始発
    if t < S[s]:
        t = S[s]
    # タイムラグ
    elif t % F[s]:
        t += F[s] - t % F[s]
    # 列車の移動時間
    t += C[s]
    return t


def main():
    # 出発駅
    for i in range(N - 1):
        t = next(i, 0)
        # 途中駅
        for j in range(i + 1, N - 1):
            t = next(j, t)
        print(t)
    print((0))
    return


main()

N = int(eval(input()))
CSFn = [[int(j) for j in input().split()] for i in range(N - 1)]


def next(s):
    t = 0
    for Ci, Si, Fi in CSFn[s:]:
        # 始発
        if t < Si:
            t = Si
        # タイムラグ
        elif t % Fi:
            t += Fi - t % Fi
        # 列車の移動時間
        t += Ci
    return t


def main():
    # 出発駅
    for i in range(N - 1):
        t = next(i)
        print(t)
    print((0))
    return


main()

-C = [] -S = [] -F = [] -for i in range(N - 1): -    c, s, f = list(map(int, input().split())) -    C.append(c) -    S.append(s) -    F.append(f) +CSFn = [[int(j) for j in input().split()] for i in range(N - 1)] -def next(s, t): -    # 始発 -    if t < S[s]: -        t = S[s] -    # タイムラグ -    elif t % F[s]: -        t += F[s] - t % F[s] -    # 列車の移動時間 -    t += C[s] +def next(s): +    t = 0 +    for Ci, Si, Fi in CSFn[s:]: +        # 始発 +        if t < Si: +            t = Si +        # タイムラグ +        elif t % Fi: +            t += Fi - t % Fi +        # 列車の移動時間 +        t += Ci -        t = next(i, 0) -        # 途中駅 -        for j in range(i + 1, N - 1): -            t = next(j, t) +        t = next(i)