While changing the decoration, there are always new modes! "Radzinka Dobramil…
- User
While changing the decoration, there are always new modes! "Radzinka Dobramil Vycheslavovich"
For example, when Quera finally managed to change the decor of his company, they had to re-open and rearrange the cartoons that the members had closed a few days ago. Before the change, they arranged these boxes in a row, and during the change, the order of these boxes got messed up. Therefore, the members decided to rearrange the boxes before opening them and put them back in order to speed up their arrangement. They know that the box is now in place i iam is located, before the change in location a i a i It was M.
Now they have hired some workers (unable to do it themselves) to arrange the boxes for them. They can tell a worker every second that the box is in place i i with box in place J j and it takes only one second for each worker. The only catch is that when a worker was told that the box was in place i i with box in place J j changes, another worker cannot be told that the box in the location i i or J replace j with another box; That is, in that second, no other operation can be done on these two boxes, or in other words, only one operation can be done on each box per second. Note that workers work in parallel every second.
Unfortunately, Quera's rival sites took advantage of Quera's distance and held a competition. Therefore, the team decides to return to the field as soon as possible. So he wants to see the boxes sorted in the shortest possible time. Now the team wants you to help the workers sort the boxes and tell them how and in what order to sort the boxes. Pay attention that the team has no restrictions on hiring workers and can hire as many workers as it wants.
input In the first line of input number n n is said to represent the number of boxes.
Then in the next line n n is the number that is the number i i'm a i a i and represents the previous location of the box that is now in the location i iam is located Pay attention that no two boxes have the same previous location; That is, in the second line of the input, you get a permutation of 1 n n is given.
1 ≤ n ≤ 100
000 1≤n≤100 000 1 ≤ a i ≤ n 1≤a i ≤n
output In the first line of the output, print the minimum number of seconds it takes them to sort the boxes.
Then, in the following lines, output the description of each second as follows:
First, output the number of operations in this second.
Then in the next lines, in each line, an operation as " a a b b" output which represents that a worker is in the box at the location this second a a with the box in place b change b
If there are several answers, print one as desired.
Example Sample entry 1 4 2 1 4 3 Plain text Sample output 1 1 2 1 2 3 4 Plain text Sample input 2 3 3 2 1 Plain text Sample output 2 1 1 1 3 Plain text Sample entry 3 3 2 3 1 Plain text Sample output 3 2 1 1 2 1 1 3 write in c++
- Assistantcpp