Problem: On the number line there are points, -th of which has integer coordinate and integer weight . The coordinates of all points are different, and the points are numbered from to .
A sequence of segments is called system of nested segments if for each pair () the condition is satisfied. In other words, the second segment is strictly inside the first one, the third segment is strictly inside the second one, and so on.
For a given number , find a system of nested segments such that:
- both ends of each segment are one of given points;
- the sum of the weights of the points used as ends of the segments is minimal.
For example, let . The given points are marked in the picture, their weights are marked in red, their coordinates are marked in blue. Make a system of three nested segments:
- weight of the first segment:
- weight of the second segment:
- weight of the third segment:
- sum of the weights of all the segments in the system:
System of three nested segments
Input Format: The first line of input data contains an integer () —the number of input test cases.
An empty line is written before each test case.
The first line of each test case contains two positive integers () and ().
The next lines contain pairs of integers () and () — coordinate and weight of point number () respectively. All are different.
It is guaranteed that the sum of values over all test cases does not exceed .
Output Format: For each test case, output lines: in the first of them, output the weight of the composed system, and in the next lines output exactly two numbers — the indices of the points which are the endpoints of the -th segment (). The order in which you output the endpoints of a segment is not important — you can output the index of the left endpoint first and then the number of the right endpoint, or the other way around.
If there are several ways to make a system of nested segments with minimal weight, output any of them.
Note: The first test case coincides with the example from the condition. It can be shown that the weight of the composed system is minimal.
The second test case has only points, so you need to use each of them to compose segments.