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;
int testnum;
int n;
const int maxn = 100005;
int a[maxn];
vector<vector<int> > cycles;
vector<vector<int> > bs;
vector<vector<int> > cs;
vector<vector<int> > b;
vector<vector<int> > c;
vector<vector<int> > b2;
vector<vector<int> > c2;
vector<vector<int> > b3;
vector<vector<int> > b33;
vector<vector<int> > c3;
vector<vector<int> > c33;
vector<vector<int> > b4;
vector<vector<int> > c4;
bool done[maxn];
void preprocess() {}
void solve() {
  memset(done, false, sizeof done);
  for (int i = 0; i < n; i++) {
    if (done[i]) continue;
    vector<int> cur;
    int j = i;
    while (!done[j]) {
      cur.push_back(j);
      done[j] = true;
      j = a[j];
    }
    cycles.push_back(cur);
  }
  for (int i = 0; i < cycles.size(); i++) {
    int rem = cycles[i].size();
    if (rem == 1) continue;
    if (rem <= 5) {
      vector<int> cb;
      vector<int> cc;
      for (int j = 0; j < rem; j++) {
        cb.push_back(cycles[i][j]);
        cc.push_back(cycles[i][(j + 1) % rem]);
      }
      bs.push_back(cb);
      cs.push_back(cc);
    } else {
      vector<int> cb;
      vector<int> cc;
      for (int j = rem - 5; j < rem; j++) {
        cb.push_back(cycles[i][j]);
        cc.push_back(cycles[i][(j - rem + 6) % 5 + (rem - 5)]);
      }
      bs.push_back(cb);
      cs.push_back(cc);
      cycles[i].resize(rem - 4);
      i--;
    }
  }
  for (int i = 0; i < bs.size(); i++) {
    int len = bs[i].size();
    if (len == 2) {
      b2.push_back(bs[i]);
      c2.push_back(cs[i]);
    } else if (len == 3) {
      b33.push_back(bs[i]);
      c33.push_back(cs[i]);
    } else {
      b.push_back(bs[i]);
      c.push_back(cs[i]);
    }
  }
  int n2 = b2.size();
  int n3 = b33.size();
  int nmin = min(n2, n3);
  if (true) {
    for (int i = 0; i < n3; i++) {
      int j = i - (n2 - 1);
      if (j % 3 == 0 && j > 0) {
        vector<int> a1, a2, a3, a4;
        a1.push_back(b33[i][0]);
        a1.push_back(b33[i][1]);
        a2.push_back(c33[i][0]);
        a2.push_back(c33[i][2]);
        b2.push_back(a1);
        c2.push_back(a2);
        a3.push_back(b33[i][0]);
        a3.push_back(b33[i][2]);
        a4.push_back(c33[i][1]);
        a4.push_back(c33[i][2]);
        b2.push_back(a3);
        c2.push_back(a4);
      } else {
        b3.push_back(b33[i]);
        c3.push_back(c33[i]);
      }
    }
  }
  n2 = b2.size();
  n3 = b3.size();
  nmin = min(n2, n3);
  for (int i = 0; i < nmin; i++) {
    vector<int> tb;
    vector<int> tc;
    tb.push_back(b2[i][0]);
    tb.push_back(b2[i][1]);
    tb.push_back(b3[i][0]);
    tb.push_back(b3[i][1]);
    tb.push_back(b3[i][2]);
    tc.push_back(c2[i][0]);
    tc.push_back(c2[i][1]);
    tc.push_back(c3[i][0]);
    tc.push_back(c3[i][1]);
    tc.push_back(c3[i][2]);
    b.push_back(tb);
    c.push_back(tc);
  }
  if (n2 < n3)
    for (int i = nmin; i < n3; i++) {
      vector<int> tb;
      vector<int> tc;
      tb.push_back(b3[i][0]);
      tb.push_back(b3[i][1]);
      tb.push_back(b3[i][2]);
      tc.push_back(c3[i][0]);
      tc.push_back(c3[i][1]);
      tc.push_back(c3[i][2]);
      b.push_back(tb);
      c.push_back(tc);
    }
  if (n3 < n2)
    for (int i = nmin; i < n2; i++) {
      vector<int> tb;
      vector<int> tc;
      tb.push_back(b2[i][0]);
      tb.push_back(b2[i][1]);
      tc.push_back(c2[i][0]);
      tc.push_back(c2[i][1]);
      i++;
      if (i < n2) {
        tb.push_back(b2[i][0]);
        tb.push_back(b2[i][1]);
        tc.push_back(c2[i][0]);
        tc.push_back(c2[i][1]);
      }
      b.push_back(tb);
      c.push_back(tc);
    }
  printf("%d\n", b.size());
  for (int i = 0; i < b.size(); i++) {
    printf("%d\n", b[i].size());
    for (int j = 0; j < b[i].size(); j++) printf("%d ", b[i][j] + 1);
    printf("\n");
    for (int j = 0; j < b[i].size(); j++) printf("%d ", c[i][j] + 1);
    printf("\n");
  }
}
bool input() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  return true;
}
int main() {
  preprocess();
  int T = 1;
  for (testnum = 1; testnum <= T; testnum++) {
    if (!input()) break;
    solve();
  }
}