N = int(input())

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



for i in range(N-1):

    ans = CSF[i][0] + CSF[i][1]

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

        s, t, u = CSF[j][0], CSF[j][1], CSF[j][2]

        if t < ans:

            n = (ans - t) / u if ((ans - t) % u) == 0 else (ans - t) / u + 1

            ans = s + t + u * n

        else:

            ans = s + t



    print(ans)



print(0)
N = int(input())

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



for i in range(N):

    ans = 0

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

        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2]

        if ans < S:

            ans = S

        elif ans % F == 0:

            pass

        else:

            ans = (ans / F + 1) * F

        ans += C



    print(ans)

N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N - 1)]
for i in range(N - 1):
    ans = CSF[i][0] + CSF[i][1]
    for j in range(i + 1, N - 1):
        s, t, u = CSF[j][0], CSF[j][1], CSF[j][2]
        if t < ans:
            n = (ans - t) / u if ((ans - t) % u) == 0 else (ans - t) / u + 1
            ans = s + t + u * n
        else:
            ans = s + t
    print(ans)
print(0)

N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N - 1)]
for i in range(N):
    ans = 0
    for j in range(i, N - 1):
        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2]
        if ans < S:
            ans = S
        elif ans % F == 0:
            pass
        else:
            ans = (ans / F + 1) * F
        ans += C
    print(ans)

-for i in range(N - 1): -    ans = CSF[i][0] + CSF[i][1] -    for j in range(i + 1, N - 1): -        s, t, u = CSF[j][0], CSF[j][1], CSF[j][2] -        if t < ans: -            n = (ans - t) / u if ((ans - t) % u) == 0 else (ans - t) / u + 1 -            ans = s + t + u * n +for i in range(N): +    ans = 0 +    for j in range(i, N - 1): +        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2] +        if ans < S: +            ans = S +        elif ans % F == 0: +            pass -            ans = s + t +            ans = (ans / F + 1) * F +        ans += C -print(0)