시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 512 MB 7 6 5 83.333%

문제

Zenyk has a permutation of n integers from 1 to n, inclusive. His task is to sort the permutation, and he has to swap each pair of integers exactly once.

Can you help him to do that?

입력

The first line contains a single integer n (2 ≤ n ≤ 1000). The second line contains the permutation P of integers between 1 and n.

출력

Print “no” if it’s impossible to sort the permutation. Otherwise, print n(n−1)/2 lines that describe the pairs of values (not indices) to swap on the corresponding turn.

예제 입력 1

4
3 2 4 1

예제 출력 1

1 2
4 1
1 3
2 3
2 4
3 4

예제 입력 2

3
1 3 2

예제 출력 2

1 3
3 2
1 2

예제 입력 3

2
1 2

예제 출력 3

no