program abc084c
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j
    integer(int32):: time, nt
    integer(int32), allocatable:: c(:), s(:), f(:),ans(:)=0

    read*, n
    allocate(c(n-1), s(n-1), f(n-1), ans(n))

    do i=1,n-1
        read*, c(i),s(i),f(i)
    end do

    do j=1,n-1
        time=0
        do i=j,n-1
            if (time <= s(i)) then
                time = s(i)+c(i)
            else
                nt=s(i)
                do while(time > nt)
                    nt=nt+f(i)
                end do
                time=nt+c(i)
            end if
        end do
        ans(j)=time
    end do

    print'(i0)', ans(:)
end program abc084c