cat

Time limit: 1s Memory limit: 256MB Input: Output:

The cat Motanel’s favourite activity is sorting. She generally has a row of NN blocks in front of her, of distinct sizes, and she tries to sort these in increasing order of size, by using a sequence of swaps. Since cat’s like pairing things, NN is even. Unfortunately, the dastardly rat Sobo, tries to trick Motanel, and, each time Motanel swaps the ithi^{\text{th}} block and the jthj^{\text{th}} block, Sobo will then swap the blocks on positions (Ni+1)(N-i+1) and (Nj+1)(N-j+1). How can Motanel optimally sort the blocks ?

More formally, you are given a permutation P1,P2,,PNP_1, P_2, \dots, P_N. An operation on indices (i,j)(i, j) is defined to swap PiP_i and PjP_j , and then to swap PNi+1P_{N-i+1} and PNj+1P_{N-j+1}.

Task

Given NN and PP, create a minimal sequence of operations that sorts PP.

Input data

There will be multiple test cases in each input file.

On the first line of the input there will be an integer that represents the number of test cases in this file.

On the first line of each test case there will be an integer that represents the value of NN.

On the next line of each test case will follow 𝑁 integers, that represent P1,P2,PNP_1, P_2, \dots P_N respectively.

Output data

Output the answers to the TT test cases in order.

If there is no way of sorting the permutation, simply print 1-1 on a new line.

Otherwise, begin by outputting a line that contains two integers gg and LL, which represent the length that you think a minimal sequence of operations has, and the length that your sequence of operations has (for partial points, these can be different). Then continue by outputting LL further lines, each of which will contain two integers ii and jj. Such a line represents an operation on indices (i,j)(i,j). Note you may choose to let L=0L = 0 if you don’t aim at scoring the reconstruction points, for more details see section Scoring. You’ll get 00 points on the subtask of a test if you ever print a negative LL, or make an invalid move. An invalid move (i,j)(i,j) either has i=ji = j or one of the positions out of the range [1,N][1, N].

Restrictions

In all tests, 2N200 0002 \leq N \leq 200 \ 000, NN is even and PP is a permutation: any value between 11 and NN appears exactly once in PP.

Subtask Score Restrictions
1 15 T4 000T \leq 4 \ 000 and N10N \leq 10
2 10 T104T \leq 10^4 and sum of N2 over all tests107\text{sum of } N^2 \text{ over all tests} \leq 10^7 and PiN2P_i \leq \frac{N}{2} for any 1iN21 \leq i \leq \frac{N}{2}
3 25 T104T \leq 10^4 and sum of N2 over all tests107\text{sum of } N^2 \text{ over all tests} \leq 10^7
4 15 T104T \leq 10^4 and sum of N over all tests3106\text{sum of } N \text{ over all tests} \leq 3 \cdot 10^6 and PiN2P_i \leq \frac{N}{2} for any 1iN21 \leq i \leq \frac{N}{2}
5 35 T104T \leq 10^4 and sum of N over all tests3106\text{sum of } N \text{ over all tests} \leq 3 \cdot 10^6

Scoring

Each subtask will be scored independently. The score you’ll get is the score assigned to the subtask multiplied with the minimum ratio among all tests of that subtask. The ratio of a test is computed as follows:

  • If there is any subtest where you haven’t properly decided whether a solution exists or not, then the ratio is 00
  • If you’ve made throughout the whole test more than 31063 \cdot 10^6 moves, the ratio is 00
  • If you’ve given a correct optimal reconstruction of moves for all subtests inside the test, the ratio for that test is 1.01.0 (regardless of whether your guess of optimal length was correct)
  • If you’ve computed the correct optimal number of moves and gave a correct, solution for all subtests inside the test, the ratio for that test is 0.70.7
  • If you’ve computed the correct optimal number of moves, the ratio is 0.40.4
  • If you’ve given a correct reconstruction of moves for every subtest that was solvable, the ratio is 0.350.35
  • If you have at least one wrong reconstruction for a subtest, provided you’ve correctly distinguished between when you can sort the permutation and when you can’t, the ratio for the test is 0.150.15

Assume these criteria are considered in this exact order and the coefficient is given by the first condition that matches the case of the current test.

Example

stdin

4
6
2 6 4 3 1 5
10
4 9 6 3 1 10 8 5 2 7
4
4 1 3 2
10
7 8 9 10 5 6 1 2 3 4

stdout

3 3
2 4
2 3
1 2
5 5
2 8
2 5
1 4
1 3
1 2
-1
2 2
2 8
1 7

Log in or sign up to be able to send submissions!