文理学院程序设计在线练习


eat candy

Time Limit: 1 Second(s)    Memory Limit: 128 MB

Total Submission(s): 0   Accepted Submission(s): 0
Problem Description

Little A likes to eat candy, there are n candy hanging in the sky with a rope, each candy has three attributes: ti (sugar species), hi (sugar height), mi (sugar energy). Little A can jump x meters at the beginning, after eating candy I, jumping ability will increase mi meters. Little A doesn't like to eat two candies of the same kind continuously. How much candy does Little A eat at most?

Input

The first line is a positive integer T (T<=100), which represents the number of cases
For each case, the first line is two positive integers n, x (1<=n<=10000; 1<=x<=2000).
Next n lines, three numbers per line: ti,hi,mi(0<=ti<=1;1<= hi,mi<=2000)。

Output

Output one line per case, that is, the amount of candy that little A can eat at most.

Sample Input
1
5 2
1 15 2
1 11 2
0 17 2
0 16 1
1 18 2
Sample Output
0
Source

2017绍兴市技能竞赛