integer N
integer,allocatable,dimension(:)::C,S,F
integer T
read*,N
allocate(C(N),S(N),F(N))
do i=1,N-1
  read*,C(i),S(i),F(i)
end do

do i=1,N
  T=0
  do j=i,N-1
    if(T<=S(j))then
      T=S(j)
    else if(mod(T,F(j))/=0)then
      T=T+F(j)-mod(T,F(j))
    endif
    T=T+C(j)
  end do
  print"(i0)",T
end do
end