As a master of parallel computing, schwer is recently considering about the method to achieve quick sorting on parallel computers. He needs your help!
Given a permutation , you need to sort the permutation with minimum number of rounds. In a single round, one can take many pairs of integers
as long as the values of
are pairwise distinct. Then with the help of
CPUs, for each
, the value of
and
will be switched immediately. Note that a permutation
is sorted if for every integer
,
holds.
Take some examples. Assume that . For
, the minimum number of round is
as it is already sorted. For
, the answer is
, as you can swap the indices
and
simultaneously.
he first line of input contains a single integer
, indicating the length of the permutation.
The second line contains
integers
, the given permutation. It is guaranteed that these integers form a permutation, that is, for every integer
there exists an unique integer
such that
.
The first line of output should contain a single integer
, the minimum number of rounds to get the permutation sorted. Then print
line to show one possible solution.
The
-th of the next
lines should describe the
-th round of your solution, beginning with a single integer
, and followed by
integers
. The constraints that
and the
integers are pairwise distinct must be held.