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 T gcd(T a, T b) {
  T t;
  while (a && b) t = a, a = b % a, b = t;
  return a + b;
}
template <class T>
inline T power(T a, int p) {
  T r = T(1);
  while (p) {
    if (p & 1) r = r * a;
    a = a * a;
    p >>= 1;
  }
  return r;
}
template <class T>
T extgcd(T a, T b, T& x, T& y) {
  if (b == 0) return x = 1, y = 0, a;
  T x1, y1, g;
  g = extgcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - a / b * y1;
  return g;
}
template <class T>
inline T Floor(T a, T b) {
  if (b < 0) a = -a, b = -b;
  if (a < 0) return (a - b + 1) / b;
  return a / b;
}
template <class T>
inline T Ceil(T a, T b) {
  if (b < 0) a = -a, b = -b;
  if (a < 0) return a / b;
  return (a + b - 1) / b;
}
int N, M, K;
int a[111111];
bool w[111111];
vector<vector<int> > sol[6];
vector<pair<vector<int>, vector<int> > > gsol;
void solve(vector<int>& v) {
  int n = ((int)v.size());
  int last = n - 1;
  while (last >= 0) {
    int cur = max(0, last - 4);
    vector<int> tmp;
    for (int j = cur; j <= last; ++j) tmp.push_back(v[j]);
    sol[((int)tmp.size())].push_back(tmp);
    if (cur == 0) {
      last = -1;
    } else {
      last = cur;
    }
  }
}
void output(vector<int>& v, int s) {
  for (int i = 0; i < s; ++i) printf("%d%c", v[i], i == s - 1 ? '\n' : ' ');
}
vector<int> shiftl(vector<int>& v) {
  int ss = ((int)v.size());
  vector<int> tmp;
  for (int j = 1; j < ss; ++j) tmp.push_back(v[j]);
  tmp.push_back(v[0]);
  return tmp;
}
int s[6];
int main() {
  scanf("%d", &N);
  int tmp;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &tmp);
    a[i + 1] = tmp;
  }
  vector<vector<int> > v;
  for (int i = 1; i < N + 1; ++i) {
    if (w[i] || i == a[i]) continue;
    vector<int> t;
    int cur = a[i];
    t.push_back(i);
    while (cur != i) {
      t.push_back(cur);
      w[cur] = true;
      cur = a[cur];
      w[cur] = true;
    }
    v.push_back(t);
  }
  for (int i = 0; i < ((int)v.size()); ++i) {
    solve(v[i]);
  }
  for (int i = 0; i < ((int)sol[5].size()); ++i)
    gsol.push_back(make_pair(sol[5][i], shiftl(sol[5][i])));
  int mn = min(((int)sol[3].size()) - s[3], ((int)sol[2].size()) - s[2]);
  for (int i = 0; i < mn; ++i) {
    vector<int>& s3 = sol[3][s[3] + i];
    vector<int>& s2 = sol[2][s[2] + i];
    vector<int> ss3 = shiftl(s3);
    vector<int> ss2 = shiftl(s2);
    for (int j = 0; j < 2; ++j) {
      s3.push_back(s2[j]);
      ss3.push_back(ss2[j]);
    }
    gsol.push_back(make_pair(s3, ss3));
  }
  s[3] += mn;
  s[2] += mn;
  mn = min(((int)sol[4].size()) - s[4],
           min(((int)sol[3].size()) - s[3], ((int)sol[2].size()) - s[2]));
  for (int i = 0; i < mn; ++i) {
    vector<int>& cur = sol[4][s[4] + i];
    vector<int> t3 = vector<int>(cur.begin() + 1, cur.end());
    vector<int> tt3 = shiftl(t3);
    vector<int>& e2 = sol[2][s[2] + i];
    vector<int> ee2 = shiftl(e2);
    for (int j = 0; j < 2; ++j) {
      t3.push_back(e2[j]);
      tt3.push_back(ee2[j]);
    }
    vector<int> t2 = vector<int>(cur.begin(), cur.begin() + 2);
    vector<int> tt2 = shiftl(t2);
    vector<int>& e3 = sol[3][s[3] + i];
    vector<int> ee3 = shiftl(e3);
    for (int j = 0; j < 3; ++j) {
      t2.push_back(e3[j]);
      tt2.push_back(ee3[j]);
    }
    gsol.push_back(make_pair(t3, tt3));
    gsol.push_back(make_pair(t2, tt2));
  }
  s[2] += mn;
  s[3] += mn;
  s[4] += mn;
  for (int i = s[4]; i < ((int)sol[4].size()); ++i)
    gsol.push_back(make_pair(sol[4][i], shiftl(sol[4][i])));
  int t3 = (((int)sol[3].size()) - s[3]) / 3;
  for (int i = 0; i < t3; ++i) {
    vector<int>& c1 = sol[3][s[3] + i * 3 + 0];
    vector<int>& c2 = sol[3][s[3] + i * 3 + 1];
    vector<int>& c3 = sol[3][s[3] + i * 3 + 2];
    vector<int> t1 = vector<int>(c1.begin() + 1, c1.end());
    vector<int> tt1 = shiftl(t1);
    vector<int> cc2 = shiftl(c2);
    for (int j = 0; j < 3; ++j) {
      t1.push_back(c2[j]);
      tt1.push_back(cc2[j]);
    }
    vector<int> t2 = vector<int>(c1.begin(), c1.begin() + 2);
    vector<int> tt2 = shiftl(t2);
    vector<int> cc3 = shiftl(c3);
    for (int j = 0; j < 3; ++j) {
      t2.push_back(c3[j]);
      tt2.push_back(cc3[j]);
    }
    gsol.push_back(make_pair(t1, tt1));
    gsol.push_back(make_pair(t2, tt2));
  }
  s[3] += t3 * 3;
  for (int i = s[3]; i < ((int)sol[3].size()); ++i)
    gsol.push_back(make_pair(sol[3][i], shiftl(sol[3][i])));
  int mn2 = (((int)sol[2].size()) - s[2]) / 2;
  for (int i = 0; i < mn2; ++i) {
    vector<int>& s1 = sol[2][s[2] + i * 2];
    vector<int>& s2 = sol[2][s[2] + i * 2 + 1];
    vector<int> ss1 = shiftl(s1);
    vector<int> ss2 = shiftl(s2);
    for (int j = 0; j < 2; ++j) {
      s1.push_back(s2[j]);
      ss1.push_back(ss2[j]);
    }
    gsol.push_back(make_pair(s1, ss1));
  }
  s[2] += mn2 * 2;
  for (int i = s[2]; i < ((int)sol[2].size()); ++i)
    gsol.push_back(make_pair(sol[2][i], shiftl(sol[2][i])));
  printf("%d\n", ((int)gsol.size()));
  for (int i = 0; i < ((int)gsol.size()); ++i) {
    pair<vector<int>, vector<int> >& cur = gsol[i];
    int ss = ((int)cur.first.size());
    printf("%d\n", ss);
    output(cur.first, ss);
    output(cur.second, ss);
  }
  return 0;
}