Problem: Yesterday was a fair in a supermarket's grocery section. There were n jars with spices on the fair. Before the event the jars were numbered from 1 to n from the left to the right. After the event the jars were moved and the grocer had to sort them by the increasing of the numbers.

The grocer has a special machine at his disposal. The machine can take any 5 or less jars and rearrange them in the way the grocer wants. Note that the jars do not have to stand consecutively. For example, from the permutation 2, 6, 5, 4, 3, 1 one can get permutation 1, 2, 3, 4, 5, 6, if pick the jars on the positions 1, 2, 3, 5 and 6. 

Which minimum number of such operations is needed to arrange all the jars in the order of their numbers' increasing?

Input

The first line contains an integer n (1 ≤ n ≤ 105). The second line contains n space-separated integers ai (1 ≤ ai ≤ n) — the i-th number represents the number of a jar that occupies the i-th position. It is guaranteed that all the numbers are distinct.

Output

Print on the first line the least number of operations needed to rearrange all the jars in the order of the numbers' increasing. Then print the description of all actions in the following format.

On the first line of the description of one action indicate the number of jars that need to be taken (k), on the second line indicate from which positions the jars need to be taken (b1, b2, ..., bk), on the third line indicate the jar's new order (c1, c2, ..., ck). After the operation is fulfilled the jar from position bi will occupy the position ci. The set (c1, c2, ..., ck) should be the rearrangement of the set (b1, b2, ..., bk).

If there are multiple solutions, output any.

Examples

Input

6
3 5 6 1 2 4


Output

2
4
1 3 6 4 
3 6 4 1 
2
2 5 
5 2 


Input

14
9 13 11 3 10 7 12 14 1 5 4 6 8 2


Output

3
4
2 13 8 14 
13 8 14 2 
5
6 7 12 5 10 
7 12 6 10 5 
5
3 11 4 1 9 
11 4 3 9 1 

Note

Let's consider the first sample. The jars can be sorted within two actions.

During the first action we take the jars from positions 1, 3, 6 and 4 and put them so that the jar that used to occupy the position 1 will occupy the position 3 after the operation is completed. The jar from position 3 will end up in position 6, the jar from position 6 will end up in position 4 and the jar from position 4 will end up in position 1.

After the first action the order will look like that: 1, 5, 3, 4, 2, 6. 

During the second operation the jars in positions 2 and 5 will change places.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD2 solver = new TaskD2();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD2 {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] p = Utils.readIntArray(in, n);
        int[] ip = p.clone();
        for (int i = 0; i < n; ++i) {
            --p[i];
        }

        int[] u = new int[n];
        int color = 1;

        List<Integer>[] smallPerms = new ArrayList[2];
        smallPerms[0] = new ArrayList<Integer>();
        smallPerms[1] = new ArrayList<Integer>();
        temp = new int[n];

        List<ResultItem> result = new ArrayList<ResultItem>();
        for (int i = 0; i < n; ++i) {
            if (u[i] == 0) {
                int size = markPermutation(i, p, u, color++);
                if (size >= 2 && size <= 3) {
                    smallPerms[size - 2].add(p[i]);
                } else if (size > 3) {
                    while (size >= 5) {
                        size -= 4;
                        result.add(new ResultItem(p, i, 5));
                    }
                    if (size > 3) {
                        result.add(new ResultItem(p, i, size));
                    } else if (size > 1) {
                        smallPerms[size - 2].add(p[i]);
                    }
                }
            }
        }



        int size2 = smallPerms[0].size();
        int size3 = smallPerms[1].size();
        int best = getBest(size2, size3);

        int ptr2 = 0, ptr3 = 0;

        for (int i = 0; i < best; ++i) {
            result.add(new ResultItem(p, smallPerms[1].get(ptr3), smallPerms[1].get(ptr3 + 1), 3, 2, true));
            smallPerms[0].add(smallPerms[1].get(ptr3 + 1));
            ptr3 += 2;
        }

        while (ptr2 < smallPerms[0].size() && ptr3 < smallPerms[1].size()) {
            result.add(new ResultItem(p, smallPerms[0].get(ptr2), smallPerms[1].get(ptr3), 2, 3));
            ++ptr2;
            ++ptr3;
        }
        while (ptr2 < smallPerms[0].size()) {
            if (ptr2 < smallPerms[0].size() - 1) {
                result.add(new ResultItem(p, smallPerms[0].get(ptr2), smallPerms[0].get(ptr2 + 1), 2, 2));
                ptr2 += 2;
            } else {
                result.add(new ResultItem(p, smallPerms[0].get(ptr2), 2));
                ++ptr2;
            }
        }
        while (ptr3 < smallPerms[1].size()) {
            result.add(new ResultItem(p, smallPerms[1].get(ptr3), 3));
            ++ptr3;
        }

        out.println(result.size());
        for (ResultItem item : result) {
            out.println(item.toString());
        }

//        if (!applyResult(ip, result)) {
//            throw new AssertionError("!");
//        }
    }

    private int getBest(int size2, int size3) {
        int best = Integer.MAX_VALUE;
        int res = 0;
        for (int i = 0; i * 2 <= size3; ++i) {
            int nSize2 = size2;
            int left3 = size3 - i * 2;
            int cur = i;
            size2 += cur;
            int min = Math.min(left3, size2);
            size2 -= min;
            left3 -= min;
            cur += min;
            if (size2 > left3) {
                cur += (size2 / 2) + (size2 % 2);
            } else {
                cur += left3;
            }
            if (cur < best) {
                best = cur;
                res = i;
            }
            size2 = nSize2;
        }
        return res;
    }

    int[] temp;

    class ResultItem {

        int[] originalPositions;
        int[] newPositions;
        int size;

        ResultItem(int[] perm, int start, int start2, int size, int size2, boolean ok) {
            this.originalPositions = new int[size + size2];
            this.newPositions = new int[size + size2];
            this.size = size + size2;

            int cid = start;
            for (int i = 0; i < size; ++i) {
                originalPositions[i] = cid;
                cid = perm[cid];
                newPositions[i] = cid;
            }

//            cid = start2;
//            for (int i = 0; i < size2; ++i) {
//                originalPositions[size + i] = cid;
//                cid = perm[cid];
//                newPositions[size + i] = cid;
//            }

            ResultItem nn = new ResultItem(perm, start2, 2);
            originalPositions[size] = nn.originalPositions[0];
            originalPositions[size + 1] = nn.originalPositions[1];
            newPositions[size] = nn.newPositions[0];
            newPositions[size + 1] = nn.newPositions[1];

            for (int i = 0; i < size; ++i) {
                temp[originalPositions[i]] = perm[originalPositions[i]];
            }
            for (int i = 0; i < size; ++i) {
                perm[newPositions[i]] = temp[originalPositions[i]];
            }
        }

        public String toString() {
            StringBuilder b = new StringBuilder("");

            for (int i = 0; i < size; ++i) {
                originalPositions[i]++;
                newPositions[i]++;
            }
            b.append(size).append('\n').append(ArrayUtils.toString(originalPositions)).append('\n').append(ArrayUtils.toString(newPositions));
            for (int i = 0; i < size; ++i) {
                originalPositions[i]--;
                newPositions[i]--;
            }
            return b.toString();
        }

        ResultItem(int[] perm, int start, int size) {
            this.originalPositions = new int[size];
            this.newPositions = new int[size];
            this.size = size;

            int cid = start;
            for (int i = 0; i < size; ++i) {
                originalPositions[i] = cid;
                cid = perm[cid];
                if (i == size-1) cid = start;
                newPositions[i] = cid;
            }

            for (int i = 0; i < size; ++i) {
                temp[originalPositions[i]] = perm[originalPositions[i]];
            }
            for (int i = 0; i < size; ++i) {
                perm[newPositions[i]] = temp[originalPositions[i]];
            }
        }

        ResultItem(int[] perm, int start, int start2, int size, int size2) {
            this.originalPositions = new int[size + size2];
            this.newPositions = new int[size + size2];
            this.size = size + size2;

            int cid = start;
            for (int i = 0; i < size; ++i) {
                originalPositions[i] = cid;
                cid = perm[cid];
                newPositions[i] = cid;
            }

            cid = start2;
            for (int i = 0; i < size2; ++i) {
                originalPositions[size + i] = cid;
                cid = perm[cid];
                newPositions[size + i] = cid;
            }

            for (int i = 0; i < size + size2; ++i) {
                temp[originalPositions[i]] = perm[originalPositions[i]];
            }
            for (int i = 0; i < size + size2; ++i) {
                perm[newPositions[i]] = temp[originalPositions[i]];
            }
        }
    }

    private int markPermutation(final int start, final int[] p, int[] u, int color) {
        int v = start;
        int size = 0;
        while (u[v] != color) {
            u[v] = color;
            ++size;
            u[v] = color;
            v = p[v];
        }
        return size;
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine().trim();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

}

class Utils {
    public static int[] readIntArray(InputReader in, int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
        }
        return a;
    }

}

class ArrayUtils {

    public static String toString(int[] a) {
        StringBuilder result = new StringBuilder("");
        for (int x : a) result.append(x).append(' ');
        return result.substring(0, result.length()-1);
    }

}