program C_solution

implicit none
integer :: n,c(499),s(499),f(499)
integer :: i,j,k,t(500)

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

do i = 1, n
    t(i) = 0
    if ( i <= n-1 ) then
      do j = i , n-1
        t(i) = max( s(j), ((t(i)-1)/f(j))*f(j) + f(j) ) + c(j)
      enddo
    endif
  write(*,*) t(i)
  enddo


end program