Problem: You are given an n × m grid. Each grid cell is filled with a unique integer from 1 to nm so that each integer appears exactly once.

In one operation, you can choose an arbitrary cycle of the grid and move all integers along that cycle one space over. Here, a cycle is any sequence that satisfies the following conditions:

  * There are at least four squares. 
  * Each square appears at most once. 
  * Every pair of adjacent squares, and also the first and last squares, share an edge. 



For example, if we had the following grid:

<image>

We can choose an arbitrary cycle like this one:

<image>

To get the following grid:

<image>

In this particular case, the chosen cycle can be represented as the sequence [1, 2, 3, 6, 5, 8, 7, 4], the numbers are in the direction that we want to rotate them in.

Find any sequence of operations to sort the grid so that the array created by concatenating the rows from the highest to the lowest is sorted (look at the first picture above).

Note you do not need to minimize number of operations or sum of cycle lengths. The only constraint is that the sum of all cycles lengths must not be greater than 10^5. We can show that an answer always exists under the given constraints. Output any valid sequence of moves that will sort the grid.

Input

The first line contains two integers n and m (3 ≤ n,m ≤ 20) — the dimensions of the grid.

Each of the next n lines contains m integers x_{i,1}, x_{i,2}, …, x_{i, m} (1 ≤ x_{i,j} ≤ nm), denoting the values of the block in row i and column j. 

It is guaranteed that all x_{i,j} are distinct.

Output

First, print a single integer k, the number of operations (k ≥ 0).

On each of the next k lines, print a cycle as follows:

$$$s\ y_1\ y_2\ …\ y_s$$$

Here, s is the number of blocks to move (s ≥ 4). Here we have block y_1 moving to where block y_2 is, block y_2 moving to where block y_3 is, and so on with block y_s moving to where block y_1 is.

The sum of s over all operations must be at most 10^5.

Examples

Input

3 3
4 1 2
7 6 3
8 5 9


Output

1
8 1 4 7 8 5 6 3 2

Input

3 5
1 2 3 5 10
11 6 4 14 9
12 7 8 13 15


Output

3
4 4 14 13 8
4 5 10 9 4
4 12 7 6 11

Note

The first sample is the case in the statement. Here, we can use the cycle in reverse order to sort the grid.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, m, a[25][25];
pair<int, int> pos[405];
vector<vector<int> > ans;
inline void Op(vector<int> vec) {
  ans.emplace_back(vec);
  for (int i = 0; i < (int)vec.size(); i++) {
    assert(vec[i]);
    a[pos[vec[i]].first][pos[vec[i]].second] =
        vec[(i + vec.size() - 1) % vec.size()];
  }
  auto tmp = pos[vec[0]];
  for (int i = 1; i < (int)vec.size(); i++) {
    pos[vec[i - 1]] = pos[vec[i]];
  }
  pos[vec.back()] = tmp;
}
inline void ToRight(int x, int y) {
  if (x != n) {
    Op({a[x][y], a[x][y + 1], a[x + 1][y + 1], a[x + 1][y]});
  } else {
    Op({a[x][y], a[x][y + 1], a[x - 1][y + 1], a[x - 1][y]});
  }
}
inline void ToLeft(int x, int y) {
  if (x != n) {
    Op({a[x][y], a[x][y - 1], a[x + 1][y - 1], a[x + 1][y]});
  } else {
    Op({a[x][y], a[x][y - 1], a[x - 1][y - 1], a[x - 1][y]});
  }
}
inline void ToUp(int x, int y) {
  Op({a[x][y], a[x - 1][y], a[x - 1][y + 1], a[x][y + 1]});
}
vector<vector<pair<int, int> > > vs1, vs2;
inline void Swap(int x1, int y1, int x2, int y2) {
  if (x1 == x2) {
    if (y1 > y2) swap(y1, y2);
    if (x1 + 1 <= n && y1 + 2 <= m) {
      for (auto &vec : vs1) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 + P.first][y1 + P.second]);
        }
        Op(cur);
      }
    } else if (x1 + 1 <= n) {
      swap(y1, y2);
      for (auto &vec : vs1) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 + P.first][y1 - P.second]);
        }
        Op(cur);
      }
    } else if (y1 + 2 <= m) {
      for (auto &vec : vs1) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 - P.first][y1 + P.second]);
        }
        Op(cur);
      }
    } else {
      swap(y1, y2);
      for (auto &vec : vs1) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 - P.first][y1 - P.second]);
        }
        Op(cur);
      }
    }
  } else {
    if (x1 > x2) swap(x1, x2);
    if (x1 + 2 <= n && y1 + 1 <= m) {
      for (auto &vec : vs2) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 + P.first][y1 + P.second]);
        }
        Op(cur);
      }
    } else if (x1 + 2 <= n) {
      for (auto &vec : vs2) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 + P.first][y1 - P.second]);
        }
        Op(cur);
      }
    } else if (y1 + 1 <= m) {
      swap(x1, x2);
      for (auto &vec : vs2) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 - P.first][y1 + P.second]);
        }
        Op(cur);
      }
    } else {
      swap(x1, x2);
      for (auto &vec : vs2) {
        vector<int> cur;
        for (auto &P : vec) {
          cur.push_back(a[x1 - P.first][y1 - P.second]);
        }
        Op(cur);
      }
    }
  }
}
int main() {
  vs1.push_back({{0, 0}, {0, 1}, {1, 1}, {1, 0}});
  vs1.push_back({{0, 1}, {0, 2}, {1, 2}, {1, 1}});
  vs1.push_back({{0, 0}, {1, 0}, {1, 1}, {1, 2}, {0, 2}, {0, 1}});
  vs2 = vs1;
  for (auto &vec : vs2) {
    for (auto &P : vec) swap(P.first, P.second);
  }
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      pos[a[i][j]] = make_pair(i, j);
    }
  }
  for (int i = 1; i <= n - 2; i++) {
    for (int j = 1; j <= m; j++) {
      int fx, fy;
      tie(fx, fy) = pos[(i - 1) * m + j];
      if (fx == i && fy == j) continue;
      while (fy < j) {
        ToRight(fx, fy);
        fy++;
      }
      while (fy > j) {
        ToLeft(fx, fy);
        fy--;
      }
      if (fy < m) {
        while (fx > i) {
          ToUp(fx, fy);
          fx--;
        }
      } else {
        while (fx > i) {
          Swap(fx, fy, fx - 1, fy);
          fx--;
        }
      }
    }
  }
  for (int i = n - 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int fx, fy;
      tie(fx, fy) = pos[(i - 1) * m + j];
      if (fx == i && fy == j) continue;
      while (fy > j) {
        Swap(fx, fy, fx, fy - 1);
        fy--;
      }
      while (fy < j) {
        Swap(fx, fy, fx, fy + 1);
        fy++;
      }
      if (fy < m) {
        while (fx > i) {
          ToUp(fx, fy);
          fx--;
        }
      } else {
        while (fx > i) {
          Swap(fx, fy, fx - 1, fy);
          fx--;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) assert(a[i][j] == (i - 1) * m + j);
  printf("%d\n", (int)ans.size());
  for (auto &vec : ans) {
    printf("%d", (int)vec.size());
    for (int x : vec) printf(" %d", x);
    printf("\n");
  }
  return 0;
}