Water Slides

Statement

This problem takes place on a private island in the sea.

Around the circumference of the island there are \(n\) points where it’s possible to build infrastructure. These points are numbered from \(0\) to \(n-1\) in clockwise order.

The \(n\) points have mutually distinct altitudes. These are given: point \(i\) is \(H[i]\) meters above the sea.

The owner of the island wants to build a water park on the island. The main attraction should be a set of \(k\) water slides. Each water slide will take you on a ride across the island and in the end it will drop you into the sea.

More formally, the water slides should satisfy the following requirements:

Determine whether such a set of slides can be built. If yes, also find the best possible set of slides. For this purpose, the quality of a slide is the height difference between its endpoints, and the quality of a set of slides is the sum of their individual qualities.

You may assume that the park’s construction crew is very capable: they will take care of all the necessary landscaping and they will be able to build the slides as long as you choose the starts and ends of all slides so that:

Input format

The first line of each input file contains the number \(t\) of test cases. The specified number of test cases follows, one after another.

Each test case consists of two lines. The first line has the integers \(n\) and \(k\). The second line has the heights of the \(n\) points: the integers \(H[0], \dots, H[n-1]\).

In each test case:

Output format

For each test case, in order, output \(k\) lines with its solution.

If there is no way of building the slides according to the rules, each of the \(k\) lines should have the form “\(-1\) \(-1\)”.

Otherwise, pick and output one optimal solution. For each slide in the optimal solution, output one line of the form “\(a_i\) \(b_i\)”, where \(a_i\) is the number of the point where the slide begins and \(b_i\) the point where it ends.

Subproblem W1 (11 points, public)

Input file: W1.in

Constraints: \(t=10\), \(n\leq 20\), \(k=1\).

Subproblem W2 (22 points, public)

Input file: W2.in

Constraints: \(t=20\), \(n\leq 10\).

Subproblem W3 (44 points, secret)

Input file: W3.in

Constraints: \(t=100\), \(n\leq 100\).

For this subproblem you can get a partial score of 10 points for correctly identifying solvable inputs, even if your collection of slides is invalid. More precisely, if you want this partial score, for unsolvable inputs you must still output the \(-1\)s, while for solvable inputs you may print any output with \(k\) lines, each containing two integers from the range \([0,n-1]\).

Subproblem W4 (23 points, secret)

Input file: W4.in

Constraints: \(t=5\), \(n\leq 100\,000\).

Example

input
2
8 1
50 20 90 30 40 10 60 80
8 3
50 20 90 30 40 10 60 80
output
2 5
2 3
6 5
7 1

Output for the first test case.

Notes about the first test case:

Output for the second test case.

Notes about the second test case: