from functools import lru_cache



def main():

    N = int(eval(input()))

    infos = []

    for i in range(1,N):

        infos.append(tuple(map(int, input().split())))



    for i in range(1,N):

        current_time = 0

        for station_number in range(i,N):

            current_time = next_arrival_time(current_time, infos[station_number -1])

        print(current_time)

    print((0))



@lru_cache(maxsize = 2**26)

def next_arrival_time(current_time, info):

    if current_time <= info[1]:

        return info[1] + info[0]



    next_time = current_time

    remainder = next_time % info[2]

    while remainder != 0:

        next_time += 1

        remainder = next_time % info[2]

    while next_time < current_time:

        next_time += info[2]



    return next_time + info[0]



main()


N = int(eval(input()))

info = []

for i in range(1,N):

    info.append(tuple(map(int, input().split())))



for i in range(N):

    t = 0

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

        if t < info[j][1]:

            t = info[j][1]

        elif t % info[j][2] == 0:

            pass

        else:

            t = t + info[j][2] - t % info[j][2]

        t += info[j][0]

    print(t)
from functools import lru_cache


def main():
    N = int(eval(input()))
    infos = []
    for i in range(1, N):
        infos.append(tuple(map(int, input().split())))
    for i in range(1, N):
        current_time = 0
        for station_number in range(i, N):
            current_time = next_arrival_time(current_time, infos[station_number - 1])
        print(current_time)
    print((0))


@lru_cache(maxsize=2**26)
def next_arrival_time(current_time, info):
    if current_time <= info[1]:
        return info[1] + info[0]
    next_time = current_time
    remainder = next_time % info[2]
    while remainder != 0:
        next_time += 1
        remainder = next_time % info[2]
    while next_time < current_time:
        next_time += info[2]
    return next_time + info[0]


main()

N = int(eval(input()))
info = []
for i in range(1, N):
    info.append(tuple(map(int, input().split())))
for i in range(N):
    t = 0
    for j in range(i, N - 1):
        if t < info[j][1]:
            t = info[j][1]
        elif t % info[j][2] == 0:
            pass
        else:
            t = t + info[j][2] - t % info[j][2]
        t += info[j][0]
    print(t)

-from functools import lru_cache - - -def main(): -    N = int(eval(input())) -    infos = [] -    for i in range(1, N): -        infos.append(tuple(map(int, input().split()))) -    for i in range(1, N): -        current_time = 0 -        for station_number in range(i, N): -            current_time = next_arrival_time(current_time, infos[station_number - 1]) -        print(current_time) -    print((0)) - - -@lru_cache(maxsize=2**26) -def next_arrival_time(current_time, info): -    if current_time <= info[1]: -        return info[1] + info[0] -    next_time = current_time -    remainder = next_time % info[2] -    while remainder != 0: -        next_time += 1 -        remainder = next_time % info[2] -    while next_time < current_time: -        next_time += info[2] -    return next_time + info[0] - - -main() +N = int(eval(input())) +info = [] +for i in range(1, N): +    info.append(tuple(map(int, input().split()))) +for i in range(N): +    t = 0 +    for j in range(i, N - 1): +        if t < info[j][1]: +            t = info[j][1] +        elif t % info[j][2] == 0: +            pass +        else: +            t = t + info[j][2] - t % info[j][2] +        t += info[j][0] +    print(t)