Given a sequence with
integers,
, Bob wants to sort the sequence in non-descending order by using the following operation a number of times.
- Bob will choose some different indices (say
),
, and move
to the position of
, move
to the position of
,
, and finally move
to the position of
. For example, if
and
, Bob chooses
indices
, then the sequence
after the operation is
.
- The cost of one operation is
.
Bob wants to sort the sequence in non-descending order at the minimal cost. Also, Bob is busy. So the total number of selected indices is no more than , i.e.
. Can you help Bob find a way to sort the sequence? If it's impossible, output
.
Input Specification
The first line of input contains two integers and
(
,
).
The second line of input contains integers
(
).
Output Specification
If it's impossible to sort the sequence in non-descending order, output in one line.
If it's possible, output one integer
in the first line, indicating the cost to sort the given sequence. Each of the following
sections contains two lines. The first line contains one integer
, the number of indices selected. The second line contains
different integers,
. If there are multiple solutions, output any one.
Note that the checker for this problem is custom and, hence, the whitespace is strict, so do not output excess whitespace.
Constraints
Subtask | Points | Additional constraints |
---|---|---|
Sample cases. | ||
Sequence | ||
Sequence | ||
Sequence | ||
No additional constraints. |
Sample Input 1
5 5
3 2 3 1 1
Sample Output 1
1
5
1 4 2 3 5
Sample Input 2
6 9
6 5 4 3 2 1
Sample Output 2
2
6
1 6 2 5 3 4
3
3 2 1
Sample Input 3
4 3
2 1 4 3
Sample Output 3
-1
Sample Input 4
2 0
2 2
Sample Output 4
0
Sample Input 5
6 8
6 5 4 3 2 1
Sample Output 5
3
2
3 4
4
1 6 2 5
2
2 1
Comments