A driver is driving a truck along a straight road from position 0 meters to position L meters. Several traffic lights are installed on the road.
Each traffic light repeats an infinite cycle: red for R seconds, then green for G seconds. At time 0, when the truck enters the road, every traffic light has just started its red phase.
The truck moves at 1 meter per second. If it reaches a traffic light while that light is red, it stops at that position and waits until the light turns green before continuing.
Compute the total time required for the truck to reach the end of the road.
The first line contains the number of traffic lights N and the road length L. (1 <= N <= 100, 1 <= L <= 1000)
Each of the next N lines contains D, R, and G for one traffic light. D is the distance from the start of the road to the traffic light, R is the duration of the red phase, and G is the duration of the green phase. (1 <= D < L, 1 <= R <= 100, 1 <= G <= 100)
The traffic lights are given in increasing order of D, and no two traffic lights are at the same position.
Print the time, in seconds, required for the truck to reach the end of the road.