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<pair<int, int> > num;
int pos[100005], vis[100005];
vector<vector<int> > record, v2, v3;
bool cmp1(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
bool cmp2(const vector<int> &a, const vector<int> &b) {
  return a.size() > b.size();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, t;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t;
    num.emplace_back(i + 1, t);
  }
  sort(num.begin(), num.end(), cmp1);
  for (int i = 0; i < n; i++) pos[num[i].first] = i + 1;
  t = 1;
  vector<int> vec;
  while (t <= n) {
    while (!vis[t]) {
      vec.push_back(t);
      vis[t] = 1;
      t = pos[t];
    }
    if (vec.size() > 1) record.push_back(vec);
    vec.clear();
    t++;
  }
  sort(record.begin(), record.end(), cmp2);
  int cnt = 0, cnt2 = 0, cnt3 = 0;
  for (int i = 0; i < record.size(); i++) {
    if (record[i].size() == 4 || record[i].size() == 5)
      cnt++;
    else if (record[i].size() > 5) {
      cnt += record[i].size() / 4;
      int k = record[i].size() % 4;
      if (k == 2)
        cnt2++;
      else if (k == 3)
        cnt3++;
    } else if (record[i].size() == 2)
      cnt2++;
    else
      cnt3++;
  }
  if (cnt2 >= cnt3) {
    cnt += cnt3;
    cnt2 -= cnt3;
    cnt += (cnt2 + 1) / 2;
  } else {
    cnt += cnt2;
    cnt3 -= cnt2;
    cnt += cnt3 / 3 * 2;
    cnt += cnt3 % 3;
  }
  cout << cnt << endl;
  for (int i = 0; i < record.size(); i++) {
    if (record[i].size() == 4 || record[i].size() == 5) {
      cout << record[i].size() << endl;
      for (int j = 0; j < record[i].size(); j++) cout << record[i][j] << ' ';
      cout << endl;
      int k = record[i].size();
      for (int j = 1; j <= k; j++) cout << record[i][j % k] << ' ';
      cout << endl;
    } else if (record[i].size() > 5) {
      int k = record[i].size();
      int sign = 1;
      while (k >= 5) {
        cout << "5" << endl;
        cout << record[i][0] << ' ';
        for (int j = sign; j < sign + 4; j++) cout << record[i][j] << ' ';
        cout << endl;
        for (int j = sign; j < sign + 4; j++) cout << record[i][j] << ' ';
        cout << record[i][0] << endl;
        sign += 4;
        k -= 4;
      }
      t = record[i].size();
      if (k == 2) {
        vec.clear();
        vec.push_back(record[i][0]);
        vec.push_back(record[i][t - 1]);
        v2.push_back(vec);
      } else if (k == 3) {
        vec.clear();
        vec.push_back(record[i][t - 2]);
        vec.push_back(record[i][t - 1]);
        vec.push_back(record[i][0]);
        v3.push_back(vec);
      } else if (k == 4) {
        cout << "4" << endl;
        cout << record[i][0] << ' ';
        for (int j = t - 3; j < t; j++) cout << record[i][j] << ' ';
        cout << endl;
        for (int j = t - 3; j < t; j++) cout << record[i][j] << ' ';
        cout << record[i][0] << endl;
      }
    } else if (record[i].size() == 2)
      v2.push_back(record[i]);
    else
      v3.push_back(record[i]);
  }
  for (int i = 0; i < min(v2.size(), v3.size()); i++) {
    cout << "5" << endl;
    cout << v2[i][0] << ' ' << v2[i][1] << ' ' << v3[i][0] << ' ' << v3[i][1]
         << ' ' << v3[i][2] << endl;
    cout << v2[i][1] << ' ' << v2[i][0] << ' ' << v3[i][1] << ' ' << v3[i][2]
         << ' ' << v3[i][0] << endl;
  }
  if (v2.size() == v3.size()) return 0;
  if (v2.size() > v3.size()) {
    t = v3.size();
    while (t < v2.size()) {
      if (v2.size() > 1 && t < v2.size() - 1) {
        cout << "4" << endl;
        cout << v2[t][0] << ' ' << v2[t][1] << ' ' << v2[t + 1][0] << ' '
             << v2[t + 1][1] << endl;
        cout << v2[t][1] << ' ' << v2[t][0] << ' ' << v2[t + 1][1] << ' '
             << v2[t + 1][0] << endl;
        t += 2;
      } else {
        cout << "2" << endl;
        cout << v2[t][0] << ' ' << v2[t][1] << endl;
        cout << v2[t][1] << ' ' << v2[t][0] << endl;
        t += 1;
      }
    }
  } else {
    t = v2.size();
    while (t < v3.size()) {
      if (v3.size() > 2 && t < v3.size() - 2) {
        cout << "5" << endl;
        cout << v3[t][0] << ' ' << v3[t][1] << ' ' << v3[t][2] << ' '
             << v3[t + 1][0] << ' ' << v3[t + 1][1] << endl;
        cout << v3[t][1] << ' ' << v3[t][2] << ' ' << v3[t][0] << ' '
             << v3[t + 1][1] << ' ' << v3[t + 1][0] << endl;
        cout << "5" << endl;
        cout << v3[t + 1][0] << ' ' << v3[t + 1][2] << ' ' << v3[t + 2][0]
             << ' ' << v3[t + 2][1] << ' ' << v3[t + 2][2] << endl;
        cout << v3[t + 1][2] << ' ' << v3[t + 1][0] << ' ' << v3[t + 2][1]
             << ' ' << v3[t + 2][2] << ' ' << v3[t + 2][0] << endl;
        t += 3;
      } else {
        cout << "3" << endl;
        cout << v3[t][0] << ' ' << v3[t][1] << ' ' << v3[t][2] << endl;
        cout << v3[t][1] << ' ' << v3[t][2] << ' ' << v3[t][0] << endl;
        t++;
      }
    }
  }
  return 0;
}