Buggy python submission (verdict: Runtime Error):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

SS = [[0]*10**7 for _ in range(N)]
for i, csf in enu(CSF):
    c, s, f = csf
    for j in range(s, 10**6, f):
        SS[i][j] = 1
# print(SS[0][:20])
# print(SS[1][:20])

for i in range(N-1):
    st = i
    sec = 0
    while st < N-1:
        # print('st', st, 'sec', sec)
        # print('st', st)
        if SS[st][sec] == 1:
            sec += CSF[st][0]
            st += 1
        else:
            sec += 1
    print(sec)
print(0)

Fixed submission:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

for i in range(N - 1):
    c, s, f = CSF[i]
    time = s + c
    for csfj in CSF[i + 1 :]:
        c, s, f = csfj
        if time < s:
            time = s
        else:
            time = f * ((time + f - 1) // f)
        time += c
    print(time)

print(0)

Buggy python submission (verdict: Runtime Error):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

SS = [[0]*10**6 for _ in range(N)]
for i, csf in enu(CSF):
    c, s, f = csf
    for j in range(s, 10**6, f):
        SS[i][j] = 1
# print(SS[0][:20])
# print(SS[1][:20])

for i in range(N-1):
    st = i
    sec = 0
    while st < N-1:
        # print('st', st, 'sec', sec)
        # print('st', st)
        if SS[st][sec] == 1:
            sec += CSF[st][0]
            st += 1
        else:
            sec += 1
    print(sec)
print(0)

Fixed submission:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

for i in range(N - 1):
    c, s, f = CSF[i]
    time = s + c
    for csfj in CSF[i + 1 :]:
        c, s, f = csfj
        if time < s:
            time = s
        else:
            time = f * ((time + f - 1) // f)
        time += c
    print(time)

print(0)