#include using namespace std; int N,L,t,p; main() { cin>>N>>L; for(int i=0;i>x>>w>>T; t+=x-p; if(T<=t%(2*T)+w)t=(t+2*T-1)/2/T*2*T; t+=w; p=x+w; } cout<