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;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
int cond = (long long)1;
template <class t>
void print(vector<t> ary) {
  if (cond) {
    for (__typeof((ary).begin()) it = (ary).begin(); it != (ary).end(); ++it)
      cerr << " " << *it;
    cerr << endl;
  }
}
const int sz = (int)1e5 + 11;
int in[sz];
int vis[sz];
vector<vector<int> > data[11];
vector<vector<int> > out[2];
void outt(vector<int> &ciag, vector<int> oo[2], int rem) {
  rem = min(rem, (int)ciag.size());
  int k5 = min((int)ciag.size(), rem);
  int k = ciag.size();
  for (int i = (k - k5); i <= (k - 1); ++i) oo[0].push_back(ciag[i]);
  rotate(ciag.begin() + k - k5, ciag.begin() + k - k5 + 1, ciag.begin() + k);
  for (int i = (k - k5); i <= (k - 1); ++i) oo[1].push_back(ciag[i]);
  if ((int)ciag.size() == rem)
    ciag.resize(0);
  else {
    swap(ciag.back(), ciag[ciag.size() - rem]);
    ciag.resize(ciag.size() - rem + 1);
  }
}
void _main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &in[i]);
  {
    if (cond > 0) {
      cond--;
      for (int xxx = (0); xxx < (1); ++xxx)
        cerr << 79 << " "
             << "n"
             << " " << n << endl;
      cerr.flush();
    }
  };
  for (int i = (1); i <= (n); ++i)
    if (in[i] != i && vis[i] == 0) {
      vector<int> ciag;
      int p = i;
      do {
        vis[p] = 1;
        ciag.push_back(p);
        p = in[p];
      } while (p != i);
      while (ciag.size() >= 4) {
        vector<int> oo[2];
        outt(ciag, oo, 5);
        for (int g = (0); g < (2); ++g) out[g].push_back(oo[g]);
      }
      {
        if (cond > 0) {
          cond--;
          for (int xxx = (0); xxx < (1); ++xxx)
            cerr << 93 << " "
                 << "ciag.size()"
                 << " " << ciag.size() << endl;
          cerr.flush();
        }
      };
      print(ciag);
      data[ciag.size()].push_back(ciag);
    }
  while (data[2].size() || data[3].size()) {
    while (data[2].size() && data[3].size()) {
      vector<int> oo[2];
      outt(data[2].back(), oo, 2);
      data[2].pop_back();
      outt(data[3].back(), oo, 3);
      data[3].pop_back();
      for (int g = (0); g < (2); ++g) out[g].push_back(oo[g]);
    }
    while (data[2].size()) {
      vector<int> oo[2];
      for (int g = (0); g < (2); ++g)
        if (data[2].size()) {
          outt(data[2].back(), oo, 2);
          data[2].pop_back();
        }
      for (int g = (0); g < (2); ++g) out[g].push_back(oo[g]);
    }
    if (data[3].size()) {
      vector<int> oo[2];
      outt(data[3].back(), oo, 3);
      data[3].pop_back();
      if (data[3].size()) {
        vector<int> tmp = data[3].back();
        data[3].pop_back();
        outt(tmp, oo, 2);
        data[2].push_back(tmp);
      }
      for (int g = (0); g < (2); ++g) out[g].push_back(oo[g]);
    }
  }
  printf("%d\n", (int)out[0].size());
  for (int i = (0); i < ((int)out[0].size()); ++i) {
    int g = out[0][i].size();
    printf("%d\n", g);
    for (int j = (0); j < (g); ++j) {
      if (j) printf(" ");
      printf("%d", out[0][i][j]);
    }
    printf("\n");
    for (int j = (0); j < (g); ++j) {
      if (j) printf(" ");
      printf("%d", out[1][i][j]);
    }
    printf("\n");
  }
}
int main(int argc, char **argv) {
  string p = "../gcj/source/" + string("") + argv[0][strlen(argv[0]) - 1];
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "1n") == 0) {
      freopen("1.in", "r", stdin);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "2n") == 0) {
      freopen("2.in", "r", stdin);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "3n") == 0) {
      freopen("3.in", "r", stdin);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "4n") == 0) {
      freopen("4.in", "r", stdin);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "5n") == 0) {
      freopen("5.in", "r", stdin);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "s0") == 0) {
      freopen((p + "-small-0.in").c_str(), "r", stdin);
      freopen((p + "-small-0.out").c_str(), "w", stdout);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "s1") == 0) {
      freopen((p + "-small-1.in").c_str(), "r", stdin);
      freopen((p + "-small-1.out").c_str(), "w", stdout);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "s2") == 0) {
      freopen((p + "-small-2.in").c_str(), "r", stdin);
      freopen((p + "-small-2.out").c_str(), "w", stdout);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "l0") == 0) {
      freopen((p + "-large-0.in").c_str(), "r", stdin);
      freopen((p + "-large-0.out").c_str(), "w", stdout);
    }
  for (int i = (0); i < (argc); ++i)
    if (strcmp(argv[i], "q") == 0) cond = 1 << 30;
  _main();
  return 0;
}