In order to automate his workload at the factory, Mirko wants to put up to use his old box-sorting robot. There are
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
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 following line contains
Output Specification
The first line should contain the integer
The following
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
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