#coding: utf-8 #yuki_139 n,l=map(int,raw_input().split()) now=0 time=0 for i in xrange(n): x,w,t=map(int,raw_input().split()) time+=x-now now=x next=(time/(2*t))*2*t if next+t