n=int(input())

l=[list(map(int,input().split())) for i in range(n-1)]+[[0,0,1]]

al=[]

mati=0

for i in range(n):

  now=l[i][1]+l[i][0]

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

    now=l[j][0]+l[j][1]-(-max(0,now-l[j][1])//l[j][2])*l[j][2]

  al.append(now)

print(*al,sep="\n")

def f():

  n=int(eval(input()))

  l=[list(map(int,input().split())) for i in range(n-1)]+[[0,0,1]]

  for i in range(n):

    now=0

    for a,s,d in l[i:]:

      now=a+s-(-max(0,now-s)//d)*d

    print(now)

if __name__=="__main__":

  f()
n = int(input())
l = [list(map(int, input().split())) for i in range(n - 1)] + [[0, 0, 1]]
al = []
mati = 0
for i in range(n):
    now = l[i][1] + l[i][0]
    for j in range(i + 1, n):
        now = l[j][0] + l[j][1] - (-max(0, now - l[j][1]) // l[j][2]) * l[j][2]
    al.append(now)
print(*al, sep="\n")

def f():
    n = int(eval(input()))
    l = [list(map(int, input().split())) for i in range(n - 1)] + [[0, 0, 1]]
    for i in range(n):
        now = 0
        for a, s, d in l[i:]:
            now = a + s - (-max(0, now - s) // d) * d
        print(now)


if __name__ == "__main__":
    f()

-n = int(input()) -l = [list(map(int, input().split())) for i in range(n - 1)] + [[0, 0, 1]] -al = [] -mati = 0 -for i in range(n): -    now = l[i][1] + l[i][0] -    for j in range(i + 1, n): -        now = l[j][0] + l[j][1] - (-max(0, now - l[j][1]) // l[j][2]) * l[j][2] -    al.append(now) -print(*al, sep="\n") +def f(): +    n = int(eval(input())) +    l = [list(map(int, input().split())) for i in range(n - 1)] + [[0, 0, 1]] +    for i in range(n): +        now = 0 +        for a, s, d in l[i:]: +            now = a + s - (-max(0, now - s) // d) * d +        print(now) + + +if __name__ == "__main__": +    f()