Buggy python submission (verdict: Runtime Error):
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]
lists.append(s)   
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    
    else:
        times=0
        while nums<n:
            if times>=lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[num-1][1])%lists[nums-1][2]
                    
                times+=lists[nums-1][0]
                nums+=1      
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)

Fixed submission:
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    elif nums!=n:
        times=0
        while nums<n:
            if times>lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[nums-1][1])%lists[nums-1][2]  
                    times=times+lists[nums-1][2]-a
                    times+=lists[nums-1][0]
                    nums+=1  
                else:
                    times+=lists[nums-1][0]
                    nums+=1
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lists=[]
for _ in range(n-1):
    s=list(map(int,input().split()))
    lists.append(s)   
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    else:
        times=0
        while nums<n:
            if times>=lists[nums-1][1]:
                while (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    times+=1
                times+=lists[nums-1][0]
                nums+=1
                    
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)
            

Fixed submission:
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    elif nums!=n:
        times=0
        while nums<n:
            if times>lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[nums-1][1])%lists[nums-1][2]  
                    times=times+lists[nums-1][2]-a
                    times+=lists[nums-1][0]
                    nums+=1  
                else:
                    times+=lists[nums-1][0]
                    nums+=1
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lists=[]
if n==1:
    print(0)
else:
    for _ in range(n-1):
        s=list(map(int,input().split()))
        lists.append(s)
        
    for x in range(n):
        nums=x+1
        #numsはどの駅から出発するかの駅の番号(1<=nums<=n)
        if nums==n:
            print(0)
        else:
            times=0
            while nums<n:
                if times>=lists[nums-1][1]:
                    while (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                        times+=1
                    times+=lists[nums-1][0]
                    nums+=1
                    
                elif times<lists[nums-1][1]:
                    times=lists[nums-1][1]
                    times+=lists[nums-1][0]   
                    nums+=1
                    
            print(times)
            

Fixed submission:
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    elif nums!=n:
        times=0
        while nums<n:
            if times>lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[nums-1][1])%lists[nums-1][2]  
                    times=times+lists[nums-1][2]-a
                    times+=lists[nums-1][0]
                    nums+=1  
                else:
                    times+=lists[nums-1][0]
                    nums+=1
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)