#include <bits/stdc++.h>   using namespace std;   int n, a[100001];   vector<vector<pair<int, int>>> o[6], ans;   void relax(vector<int>& m) {     o[m.size()].push_back({});     for (size_t i = 0; i < m.size(); i++)       o[m.size()].back().push_back({m[i], m[(i + 1) % m.size()]});     m.resize(1);   }   void gao(int x, int y) {     if (!y) ans.insert(ans.end(), o[x].begin(), o[x].end());     while (o[x].size() > (x == y) && o[y].size()) {       ans.push_back(o[x].back());       o[x].pop_back();       ans.back().insert(ans.back().end(), o[y].back().begin(), o[y].back().end());       o[y].pop_back();     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++)       if (a[i] != i) {         vector<int> u = {i}, m = {i};         while (a[u.back()] != i) u.push_back(a[u.back()]);         for (size_t c = 1; c < u.size(); c++) {           if (m.size() == 5) relax(m);           m.push_back(a[u[c]] = u[c]);         }         relax(m);       }     gao(5, 0);     gao(4, 0);     gao(2, 3);     while (o[3].size() >= 2) {       auto u = o[3].back();       o[3].pop_back();       o[2].push_back({{u[0].first, u[1].first}, {u[1].first, u[0].first}});       o[2].push_back({{u[1].first, u[2].first}, {u[2].first, u[1].first}});       gao(2, 3);     }     gao(2, 2);     gao(3, 0);     gao(2, 0);     printf( %d n , ans.size());     for (auto& c : ans) {       printf( %d n , c.size());       for (auto x : c) printf( %d  , x.first);       puts(  );       for (auto x : c) printf( %d  , x.second);       puts(  );     }   }   