A company is testing a technology for producing antimatter to be used as fuel in an interplanetary starship. Antimatter is produced by special experiments in a reactor.
There are $n$ known types of experiments that produce antimatter. An experiment of type $i$ adds between $l_i$ and $r_i$ grams of antimatter to the reactor's output container. For safety reasons, accumulating more than $a$ grams of antimatter in the container is forbidden.
The cost of an experiment of type $i$ is $c_i$, and the value of one gram of the antimatter produced is $10^9$.
If the experiments produce $t$ grams of antimatter in the container and the total cost of the experiments in the reactor is $s$, the profit is given by the formula $(t\cdot10^9-s)$. The company needs to develop a strategy for conducting experiments that maximizes the profit that can be guaranteed.
Depending on the results of previous experiments, the strategy determines which type of experiment to conduct or decides to stop conducting experiments. A strategy guarantees a profit of $x$ if, for every possible outcome of the experiments, first, the reactor's container holds no more than $a$ grams of antimatter, and second, the profit is at least $x$.
For example, suppose there is only one type of experiment, producing between $4$ and $6$ grams of antimatter, with a cost of $10$, and the container's capacity is $17$ grams. After conducting the experiment twice, the container may hold between $8$ and $12$ grams of antimatter. If $12$ grams have been produced, no further experiment can be conducted, because producing another $6$ grams could overflow the container. In all other cases, the experiment can be conducted a third time, resulting in between $12$ and $17$ grams of antimatter. In the worst case, the experiment must be conducted three times, with a total cost of $30$, and the profit is $(12\cdot10^9-30)=11\,999\,999\,970$.
Write a program that determines the maximum profit $x$ that can be guaranteed.
Input
The first line of the input contains two integers: $n$, the number of experiment types, and $a$, the maximum allowed amount of antimatter in the container ($1\le n\le100$, $1\le a\le2\,000\,000$).
Each of the next $n$ lines contains three integers $l_i$, $r_i$, and $c_i$: respectively, the minimum and maximum amounts of antimatter produced by an experiment of type $i$, and the cost of an experiment of that type ($1\le l_i\le r_i\le a$, $1\le c_i\le100$).
Output
The output must contain one integer: the maximum profit $x$ that can be guaranteed.
Examples
Input 1
1 17 4 6 10
Output 1
11999999970
Input 2
2 11 2 2 100 3 5 5
Output 2
9999999890
Subtasks
| Subtask | Points | Constraints: $n$ | Constraints: $a$ | Additional constraints | Required subtasks | Results during the round |
|---|---|---|---|---|---|---|
| $1$ | $10$ | $n=1$ | $1\le a\le1\,000$ | Per test | ||
| $2$ | $10$ | $1\le n\le10$ | $1\le a\le1\,000$ | $l_i=r_i$ | Per test | |
| $3$ | $20$ | $1\le n\le10$ | $1\le a\le1\,000$ | $1,2$ | Per test | |
| $4$ | $20$ | $1\le n\le100$ | $1\le a\le50\,000$ | $1$–$3$ | Per test | |
| $5$ | $4$ | $1\le n\le100$ | $1\le a\le100\,000$ | $1$–$4$ | Points | |
| $6$ | $4$ | $1\le n\le100$ | $1\le a\le200\,000$ | $1$–$5$ | Points | |
| $7$ | $4$ | $1\le n\le100$ | $1\le a\le300\,000$ | $1$–$6$ | Points | |
| $8$ | $4$ | $1\le n\le100$ | $1\le a\le400\,000$ | $1$–$7$ | Points | |
| $9$ | $4$ | $1\le n\le100$ | $1\le a\le500\,000$ | $1$–$8$ | Points | |
| $10$ | $4$ | $1\le n\le100$ | $1\le a\le800\,000$ | $1$–$9$ | Points | |
| $11$ | $4$ | $1\le n\le100$ | $1\le a\le1\,100\,000$ | $1$–$10$ | Points | |
| $12$ | $4$ | $1\le n\le100$ | $1\le a\le1\,400\,000$ | $1$–$11$ | Points | |
| $13$ | $4$ | $1\le n\le100$ | $1\le a\le1\,700\,000$ | $1$–$12$ | Points | |
| $14$ | $4$ | $1\le n\le100$ | $1\le a\le2\,000\,000$ | $1$–$13$ | Points |