N=int(eval(input()))

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



for i,csf in enumerate(CSF):

    c,s,f=csf[0],csf[1],csf[2]

    ans=c+s

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

        csf_=CSF[j]

        c_,s_,f_=csf_[0],csf_[1],csf_[2]

        while True:

            if (ans>=s_) and (ans%f_==0):

                ans+=c_

                break

            ans+=1

    print(ans)

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

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



for i,csf in enumerate(CSF):

    c,s,f=csf[0],csf[1],csf[2]

    ans=c+s

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

        csf_=CSF[j]

        c_,s_,f_=csf_[0],csf_[1],csf_[2]

        if ans<s_:

            ans=s_

        elif ans%f_!=0:

            ans=ans+f_-ans%f_

        ans+=c_

    print(ans)

print((0))
N = int(eval(input()))
CSF = [list(map(int, input().split())) for _ in range(1, N)]
for i, csf in enumerate(CSF):
    c, s, f = csf[0], csf[1], csf[2]
    ans = c + s
    for j in range(i + 1, N - 1):
        csf_ = CSF[j]
        c_, s_, f_ = csf_[0], csf_[1], csf_[2]
        while True:
            if (ans >= s_) and (ans % f_ == 0):
                ans += c_
                break
            ans += 1
    print(ans)
print((0))

N = int(eval(input()))
CSF = [list(map(int, input().split())) for _ in range(1, N)]
for i, csf in enumerate(CSF):
    c, s, f = csf[0], csf[1], csf[2]
    ans = c + s
    for j in range(i + 1, N - 1):
        csf_ = CSF[j]
        c_, s_, f_ = csf_[0], csf_[1], csf_[2]
        if ans < s_:
            ans = s_
        elif ans % f_ != 0:
            ans = ans + f_ - ans % f_
        ans += c_
    print(ans)
print((0))

-        while True: -            if (ans >= s_) and (ans % f_ == 0): -                ans += c_ -                break -            ans += 1 +        if ans < s_: +            ans = s_ +        elif ans % f_ != 0: +            ans = ans + f_ - ans % f_ +        ans += c_