In order to automate his workload at the factory, Mirko wants to put up to use his old box-sorting robot. There are boxes in the factory, and each box is labelled with a unique integer in the range to . Mirko's task is to sort the boxes in the ascending order of their labels.
The sorting robot can only perform one specific operation: given the sequence of positions, the robot can do a cyclic swap of boxes at those positions. The given sequence does not contain any position more than once.
For example, let's assume that the boxes are currently in order , and Mirko provides his robot with the sequence . The robot will then rearrange the boxes so that the second box will go to position , the first box will go to position , and the third one will take position . Obtained sequence of labels is .
Write a program that will sort the boxes using the minimal number of operations. Each sequence given to the robot can be arbitrary long.
Input Specification
The first line of input contains integer , the number of boxes in the factory.
The following line contains integers in the range to , labels of boxes in order. No integer appears twice.
Output Specification
The first line should contain the integer , the minimum number of operations required.
The following lines should contain the sequences given to the robot, one sequence per line.
Each line should start with the length of the sequence, followed by a colon, a single white space, and then space separated sequence of positions.
NOTE: There may be multiple solutions and you can output any of them.
Scoring
You will receive of the points assigned to that test case if the number of operations is not minimal but is not greater than . Of course, the operations provided should yield a sorted sequence.
Sample Input 1
3
3 2 1
Sample Output 1
1
2: 3 1
Sample Input 2
5
2 3 1 5 4
Sample Output 2
2
3: 1 2 3
2: 5 4
Sample Input 3
5
1 2 3 4 5
Sample Output 3
0
Comments