Schedule
Not all jokes land, but every solution submitted during today's competition will be evaluated after the event, not during it as is typically done.
Imagine you have submitted solutions, each labeled with a unique integer from to . The system processes these solutions in groups. Solutions with consecutive numbers can be grouped in one or more sets, and the system checks these groups in order, starting with the first. The evaluation begins at time . The system first checks all solutions in the initial group, and the authors receive the results for this group simultaneously and instantly. If there is a subsequent group, it is checked next, and the results are revealed in the same manner. This process continues until all solutions are checked and results are disclosed.
Each solution takes seconds to check, and the author's anticipation level for the result is . Before checking each group, the system requires seconds for configuration. All values , , and are integers.
For instance, if solutions numbered are checked as a group starting at seconds, the results for this group will be available at seconds. It's important to note that authors receive the results simultaneously and instantly.
If the result for the -th solution is known at the -th second, the author's anxiety level increases by . The goal is to minimize the total anxiety level for all participants.
Input Data
The first line contains () – the number of test cases. For each test case, two numbers are provided: (), () and () – representing the number of solutions and the configuration time for the system. Following this, lines are given, each containing two integers () and () – the time in seconds to check the -th solution and the author's anticipation level for this solution.
Output Data
For each test case, output the minimum total level of anxiety. Each result should be printed on a new line.
Subtasks
This task includes the following subtasks:
Example Analysis
Consider an example with test case. In this test, there are solutions, and second is required for system configuration. The values are given as and . Suppose we divide the solutions into groups as follows:
In this scenario, the results are known at seconds, and the anxiety levels for each author become . The total anxiety level is . In this example, it is not possible to achieve a total anxiety level lower than .