N = int(input())
C = [0]*(N-1)
S = [0]*(N-1)
F = [0]*(N-1)
for i in range(N-1):
    C[i],S[i],F[i] = map(int,input().split())

total_time = 0
for i in range(N-1):
    total_time = S[i]+C[i]
    for j in range(i+1,N-1):
        if total_time < S[j]:
            total_time = S[j]
        elif total_time % F[j] != 0:
            total_time = S[j]+F[j]
        total_time += C[j]
    print(total_time)
print(0)
