Buggy python submission (verdict: Time Limit Exceeded):
station_num = int(input())

if station_num == 1:
    print(0)
else:
    station_list = [[0, 0, 0] for i in range(station_num)]
    
    for i in range(station_num - 1):
        station_list[i] = input().split()
    # print(station_list)
    
    for i in range(station_num):
        count = int(station_list[i][0]) + int(station_list[i][1])
        now_position = i + 1
        while True:
            if now_position == station_num - 1 or now_position == station_num:
                print(count)
                break
            else:
                while True:
                    if count < int(station_list[now_position][1]):
                        count = int(station_list[now_position][1])
                    elif count % int(station_list[now_position][2]) == 0:
                        count += int(station_list[now_position][0])
                        now_position += 1
                        break
                    else:
                        count += 1

Fixed submission:
station_num = int(input())

if station_num == 1:
    print(0)
else:
    station_list = [[0, 0, 0] for i in range(station_num)]
    
    for i in range(station_num - 1):
        station_list[i] = input().split()
    # print(station_list)
    
    for i in range(station_num):
        count = int(station_list[i][0]) + int(station_list[i][1])
        now_position = i + 1
        while True:
            if now_position == station_num - 1 or now_position == station_num:
                print(count)
                break
            else:
                while True:
                    if count < int(station_list[now_position][1]):
                        count = int(station_list[now_position][1])
                    elif count % int(station_list[now_position][2]) == 0:
                        count += int(station_list[now_position][0])
                        now_position += 1
                        break
                    else:
                        count = count + int(station_list[now_position][2]) - (count % int(station_list[now_position][2]))

Buggy python submission (verdict: Time Limit Exceeded):
station_num = int(input())
station_list = [[0, 0, 0] for i in range(station_num)]

for i in range(station_num - 1):
    station_list[i] = input().split()
# print(station_list)

for i in range(station_num):
    count = int(station_list[i][0]) + int(station_list[i][1])
    now_position = i + 1
    while True:
        if now_position == station_num - 1 or now_position == station_num:
            print(count)
            break
        else:
            while True:
                if count < int(station_list[now_position][1]):
                    count = int(station_list[now_position][1])
                elif count % int(station_list[now_position][2]) == 0:
                    count += int(station_list[now_position][0])
                    now_position += 1
                    break
                else:
                    count += 1

Fixed submission:
station_num = int(input())

if station_num == 1:
    print(0)
else:
    station_list = [[0, 0, 0] for i in range(station_num)]
    
    for i in range(station_num - 1):
        station_list[i] = input().split()
    # print(station_list)
    
    for i in range(station_num):
        count = int(station_list[i][0]) + int(station_list[i][1])
        now_position = i + 1
        while True:
            if now_position == station_num - 1 or now_position == station_num:
                print(count)
                break
            else:
                while True:
                    if count < int(station_list[now_position][1]):
                        count = int(station_list[now_position][1])
                    elif count % int(station_list[now_position][2]) == 0:
                        count += int(station_list[now_position][0])
                        now_position += 1
                        break
                    else:
                        count = count + int(station_list[now_position][2]) - (count % int(station_list[now_position][2]))