**Problem Description**

_{i}(sugar species), h

_{i}(sugar height), m

_{i}(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<=t

_{i}<=1;1<= h

_{i},m

_{i}<=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绍兴市技能竞赛