n=int(input());l=[0]*n

for i in range(1,n):

 c,s,f=map(int,input().split())

 for j in range(i):l[j]=max(-l[j]//f*-f,s)+c

print(*l,sep='\n')

n=int(eval(input()))

l=[]

for _ in range(n-1):

  c,s,f=list(map(int,input().split()))

  for i,t in enumerate(l):

    if t>s: t=-(-t//f)*f

    else: t=s

    l[i]=t+c

  l+=[s+c]

for i in l+[0]:

  print(i)
n = int(input())
l = [0] * n
for i in range(1, n):
    c, s, f = map(int, input().split())
    for j in range(i):
        l[j] = max(-l[j] // f * -f, s) + c
print(*l, sep="\n")

n = int(eval(input()))
l = []
for _ in range(n - 1):
    c, s, f = list(map(int, input().split()))
    for i, t in enumerate(l):
        if t > s:
            t = -(-t // f) * f
        else:
            t = s
        l[i] = t + c
    l += [s + c]
for i in l + [0]:
    print(i)

-n = int(input()) -l = [0] * n -for i in range(1, n): -    c, s, f = map(int, input().split()) -    for j in range(i): -        l[j] = max(-l[j] // f * -f, s) + c -print(*l, sep="\n") +n = int(eval(input())) +l = [] +for _ in range(n - 1): +    c, s, f = list(map(int, input().split())) +    for i, t in enumerate(l): +        if t > s: +            t = -(-t // f) * f +        else: +            t = s +        l[i] = t + c +    l += [s + c] +for i in l + [0]: +    print(i)