n = int(eval(input()))

station = [tuple(map(int, input().split())) for _ in range(n-1)]



for i in range(n-1):

    res = 0

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

        c, s, f = station[j]

        if res == 0:

            res += s + c

        else:

            res += max(s-res, ((res+(f-1))//f)*f - res) + c

    print(res)

else:

    print((0))

n = int(eval(input()))

station = [tuple(map(int, input().split())) for _ in range(n-1)]



for i in range(n):

    res = 0

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

        c, s, f = station[j]

        res += max(s-res, ((res+(f-1))//f)*f - res) + c

    print(res)

n = int(eval(input()))
station = [tuple(map(int, input().split())) for _ in range(n - 1)]
for i in range(n - 1):
    res = 0
    for j in range(i, n - 1):
        c, s, f = station[j]
        if res == 0:
            res += s + c
        else:
            res += max(s - res, ((res + (f - 1)) // f) * f - res) + c
    print(res)
else:
    print((0))

n = int(eval(input()))
station = [tuple(map(int, input().split())) for _ in range(n - 1)]
for i in range(n):
    res = 0
    for j in range(i, n - 1):
        c, s, f = station[j]
        res += max(s - res, ((res + (f - 1)) // f) * f - res) + c
    print(res)

-for i in range(n - 1): +for i in range(n): -        if res == 0: -            res += s + c -        else: -            res += max(s - res, ((res + (f - 1)) // f) * f - res) + c +        res += max(s - res, ((res + (f - 1)) // f) * f - res) + c -else: -    print((0))