Box Sorting

Time limit1sMemory limit128 MB

Problem

There are N boxes in a row. Each box has a distinct number from 1 to N, and the goal is to arrange the boxes so that the numbers are in increasing order from left to right.

A robot command is a sequence of distinct positions. If the command is p_1, p_2, ..., p_k, then the box currently at position p_i moves to position p_{i+1} for every 1 <= i < k, and the box currently at position p_k moves to position p_1.

Write a program that sorts the boxes using the minimum possible number of commands.

Input

The first line contains the number of boxes N (2 <= N <= 1000).

The next line contains N distinct integers, the numbers written on the boxes in their current order.

Output

Print the number of commands X on the first line.

Then print X lines, one for each robot command in order. Each command line must contain the length of the sequence, then a colon (:), one space, and then the positions in the sequence separated by spaces.

Use this canonical optimal construction. Scan positions from 1 to N. For each unprocessed position, follow the cycle i, A_i, A_{A_i}, ..., where A_i is the box number currently at position i, until the cycle closes. Ignore cycles of length 1. For a cycle of length 2, print the two positions in reverse discovered order. For a cycle of length at least 3, print the positions in discovered order.