n = int(eval(input()))



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



for i in range(n-1):

    t = 0

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

        if t <= CSF[j][1]:

            t = CSF[j][1]

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

            pass

        else:

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

        t += CSF[j][0]

    print(t)

print((0))

n = int(eval(input()))



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



for i in range(n-1):

    t = 0

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

        c, s, f = CSF[j]

        if t <= s:

            t = s

        elif t % f == 0:

            pass

        else:

            t += f - t % f

        t += c

    print(t)

print((0))

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

n = int(eval(input()))
CSF = [tuple(map(int, input().split())) for _ in range(n - 1)]
for i in range(n - 1):
    t = 0
    for j in range(i, n - 1):
        c, s, f = CSF[j]
        if t <= s:
            t = s
        elif t % f == 0:
            pass
        else:
            t += f - t % f
        t += c
    print(t)
print((0))

-        if t <= CSF[j][1]: -            t = CSF[j][1] -        elif t % CSF[j][2] == 0: +        c, s, f = CSF[j] +        if t <= s: +            t = s +        elif t % f == 0: -            t += CSF[j][2] - t % CSF[j][2] -        t += CSF[j][0] +            t += f - t % f +        t += c