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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > ret1;
vector<vector<int> > ret2;
vector<vector<int> > two;
vector<vector<int> > three;
vector<vector<int> > four;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), check(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  for (int i = 0; i < n; ++i) {
    if (check[i] == 0) {
      check[i] = 1;
      if (i == a[i]) continue;
      vector<int> seq;
      seq.push_back(i);
      int p = a[i];
      while (check[p] == 0) {
        check[p] = 1;
        seq.push_back(p);
        p = a[p];
      }
      while (seq.size() > 5) {
        vector<int> tmp, tmp2;
        for (int j = seq.size() - 5; j < seq.size(); ++j) {
          tmp.push_back(seq[j]);
          tmp2.push_back(seq[j]);
        }
        for (int j = 1; j < 5; ++j) swap(tmp2[j - 1], tmp2[j]);
        ret1.push_back(tmp);
        ret2.push_back(tmp2);
        for (int i = 0; i < 4; ++i) seq.pop_back();
      }
      if (seq.size() == 2) two.push_back(seq);
      if (seq.size() == 3) three.push_back(seq);
      if (seq.size() == 4) four.push_back(seq);
      if (seq.size() == 5) {
        ret1.push_back(seq);
        for (int j = 1; j < 5; ++j) swap(seq[j - 1], seq[j]);
        ret2.push_back(seq);
      }
    }
  }
  int s2 = two.size();
  int s3 = three.size();
  int p4 = 0;
  if (s3 - s2 >= 3) {
    int cnt = (s3 - s2) / 3;
    if (cnt > four.size()) cnt = four.size();
    vector<int> tmp(2);
    for (int i = 0; i < cnt; ++i) {
      tmp[0] = four[i][2];
      tmp[1] = four[i][3];
      two.push_back(tmp);
      tmp[0] = four[i][1];
      tmp[1] = four[i][2];
      two.push_back(tmp);
      tmp[0] = four[i][0];
      tmp[1] = four[i][1];
      two.push_back(tmp);
    }
    p4 = cnt;
  }
  s2 = two.size();
  s3 = three.size();
  if (s3 - s2 >= 3) {
    int cnt = (s3 - s2) / 3;
    for (int i = 0; i < cnt; ++i) {
      vector<int> rr = three.back(), tmp(2);
      three.pop_back();
      tmp[0] = rr[1], tmp[1] = rr[2];
      two.push_back(tmp);
      tmp[0] = rr[0], tmp[1] = rr[1];
      two.push_back(tmp);
    }
  }
  int p = min(two.size(), three.size());
  for (int i = 0; i < p; ++i) {
    vector<int> tmp(5), tmp2(5);
    tmp[0] = two[i][0];
    tmp[1] = two[i][1];
    tmp[2] = three[i][0];
    tmp[3] = three[i][1];
    tmp[4] = three[i][2];
    tmp2[0] = two[i][1];
    tmp2[1] = two[i][0];
    tmp2[2] = three[i][1];
    tmp2[3] = three[i][2];
    tmp2[4] = three[i][0];
    ret1.push_back(tmp);
    ret2.push_back(tmp2);
  }
  for (int i = p; i < two.size(); i += 2) {
    if (i + 1 == two.size()) {
      vector<int> tmp = two[i], tmp2 = two[i];
      swap(tmp2[0], tmp2[1]);
      ret1.push_back(tmp);
      ret2.push_back(tmp2);
    } else {
      vector<int> tmp(4), tmp2(4);
      tmp[0] = two[i][0];
      tmp[1] = two[i][1];
      tmp[2] = two[i + 1][0];
      tmp[3] = two[i + 1][1];
      tmp2 = tmp;
      swap(tmp2[0], tmp2[1]);
      swap(tmp2[2], tmp2[3]);
      ret1.push_back(tmp);
      ret2.push_back(tmp2);
    }
  }
  for (int i = p; i < three.size(); ++i) {
    vector<int> tmp = three[i];
    ret1.push_back(tmp);
    for (int j = 1; j < 3; ++j) swap(tmp[j - 1], tmp[j]);
    ret2.push_back(tmp);
  }
  for (int i = p4; i < four.size(); ++i) {
    vector<int> tmp = four[i];
    ret1.push_back(tmp);
    for (int j = 1; j < 4; ++j) swap(tmp[j - 1], tmp[j]);
    ret2.push_back(tmp);
  }
  printf("%d\n", ret1.size());
  for (int i = 0; i < ret1.size(); ++i) {
    int v = ret1[i].size();
    printf("%d\n", v);
    for (int j = 0; j < v; ++j) {
      if (j) printf(" ");
      printf("%d", ret1[i][j] + 1);
    }
    printf("\n");
    for (int j = 0; j < v; ++j) {
      if (j) printf(" ");
      printf("%d", ret2[i][j] + 1);
    }
    printf("\n");
  }
}