Irreducible Permutation
시간 제한1초메모리 제한1024 MB
주어진 순열을 기약 순열로 만들기 위한 인접 교환의 최소 횟수와 그 교환 순서를 구한다.
문제
A permutation is called irreducible if none of its prefixes forms a permutation, except the permutation itself. For example, and are irreducible while and are not.
You are given a permutation of length . In one operation, you can choose any two adjacent indices and swap their values.
Find the minimum number, and the corresponding sequence, of operations to transform into an irreducible permutation. It can be shown that you can always make given permutation irreducible.
입력
The first line contains a single integer --- the number of test cases.
The first line of each test case contains a single integer .
The second line of each test case contains space-separated integers .
출력
For each test case, print two lines:
On the first line, print --- the minimum number of operations that can make irreducible.
On the second line, print space-separated integers where and are the indices you intend to swap. If there are multiple solutions, you may print any.
Note that the operations are performed sequentially in the same order specified by your output.
제한
- if
- It is guaranteed that the sum of over all test cases does not exceed .