#!/usr/bin/env python3



import math

import sys



n = int(sys.stdin.readline().strip())

f_list = []

for _ in range(n - 1):

    c, s, f = sys.stdin.readline().strip().split(" ")

    c = int(c)

    s = int(s)

    f = int(f)

    f_list = [c + math.ceil((max(_f, s)) / f) * f for _f in f_list]

    f_list.append(c + s)

f_list.append(0)

for _f in f_list:

    print(_f)
from math import ceil





def solve(string):

    n, *csf = list(map(int, string.split()))

    f_list = []

    for c, s, f in zip(csf[::3], csf[1::3], csf[2::3]):

        f_list = [c + ceil((max(_f, s)) / f) * f for _f in f_list]

        f_list.append(c + s)

    f_list.append(0)

    return "\n".join([str(_f) for _f in f_list])





if __name__ == '__main__':

    n = int(eval(input()))

    print((solve('{}\n'.format(n) + '\n'.join([eval(input()) for _ in range(n - 1)]))))

#!/usr/bin/env python3
import math
import sys

n = int(sys.stdin.readline().strip())
f_list = []
for _ in range(n - 1):
    c, s, f = sys.stdin.readline().strip().split(" ")
    c = int(c)
    s = int(s)
    f = int(f)
    f_list = [c + math.ceil((max(_f, s)) / f) * f for _f in f_list]
    f_list.append(c + s)
f_list.append(0)
for _f in f_list:
    print(_f)

from math import ceil


def solve(string):
    n, *csf = list(map(int, string.split()))
    f_list = []
    for c, s, f in zip(csf[::3], csf[1::3], csf[2::3]):
        f_list = [c + ceil((max(_f, s)) / f) * f for _f in f_list]
        f_list.append(c + s)
    f_list.append(0)
    return "\n".join([str(_f) for _f in f_list])


if __name__ == "__main__":
    n = int(eval(input()))
    print((solve("{}\n".format(n) + "\n".join([eval(input()) for _ in range(n - 1)]))))

-#!/usr/bin/env python3 -import math -import sys +from math import ceil -n = int(sys.stdin.readline().strip()) -f_list = [] -for _ in range(n - 1): -    c, s, f = sys.stdin.readline().strip().split(" ") -    c = int(c) -    s = int(s) -    f = int(f) -    f_list = [c + math.ceil((max(_f, s)) / f) * f for _f in f_list] -    f_list.append(c + s) -f_list.append(0) -for _f in f_list: -    print(_f) + +def solve(string): +    n, *csf = list(map(int, string.split())) +    f_list = [] +    for c, s, f in zip(csf[::3], csf[1::3], csf[2::3]): +        f_list = [c + ceil((max(_f, s)) / f) * f for _f in f_list] +        f_list.append(c + s) +    f_list.append(0) +    return "\n".join([str(_f) for _f in f_list]) + + +if __name__ == "__main__": +    n = int(eval(input())) +    print((solve("{}\n".format(n) + "\n".join([eval(input()) for _ in range(n - 1)]))))