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;
const double pi = acos(-1.0);
const double eps = 1e-11;
template <class T>
inline void ckmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void ckmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const int maxsize = 1024;
int n, m;
int a[maxsize][maxsize];
int saved_a[maxsize][maxsize];
vector<vector<int>> ret;
int x[maxsize], y[maxsize];
bool c[maxsize][maxsize];
void show() {
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j) {
      printf("%3d ", a[i][j]);
      if (j == m - 1) printf("\n");
    }
  printf("\n");
}
int ID(int x, int y) { return x * m + y; }
int get_dist(int id1, int id2) {
  return abs(id1 / m - id2 / m) + abs(id1 % m - id2 % m);
}
void apply(vector<int> p);
void solve(int x0, int y0) {
  int idx = ID(x0, y0);
  int src = -1;
  for (int x = 0; x < (n); ++x)
    for (int y = 0; y < (m); ++y)
      if (a[x][y] == idx) src = ID(x, y);
  assert(src >= 0);
  int current_dist = get_dist(idx, src);
  for (int dx = -1; dx <= 0; dx++)
    for (int dy = -1; dy <= 0; dy++)
      for (int b = 0; b < (2); ++b) {
        int x = src / m + dx;
        int y = src % m + dy;
        if (x < 0 || x >= n - 1 || y < 0 || y >= m - 1) continue;
        vector<int> p;
        p.push_back(ID(x, y));
        p.push_back(ID(x, y + 1));
        p.push_back(ID(x + 1, y + 1));
        p.push_back(ID(x + 1, y));
        if (b) reverse(p.begin(), p.end());
        bool ok = true;
        for (int x : p)
          if (c[x / m][x % m]) ok = false;
        if (!ok) continue;
        int next = -1;
        for (int i = 0; i < (((int)p.size())); ++i)
          if (p[i] == src) next = p[(i + 1) % ((int)p.size())];
        if (next < 0) continue;
        if (get_dist(idx, next) < current_dist) {
          for (int i = 0; i < (((int)p.size())); ++i)
            p[i] = a[p[i] / m][p[i] % m];
          apply(p);
          return;
        }
      }
  int sx = src / m, sy = src % m;
  if (sy == m - 1) {
    apply({a[sx][sy], a[sx + 1][sy], a[sx + 1][sy - 1], a[sx][sy - 1]});
    for (int i = 0; i < (2); ++i)
      apply({a[sx - 1][sy], a[sx][sy], a[sx + 1][sy], a[sx + 1][sy - 1],
             a[sx][sy - 1], a[sx - 1][sy - 1]});
    for (int i = 0; i < (2); ++i)
      apply({a[sx - 1][sy - 1], a[sx - 1][sy], a[sx][sy], a[sx][sy - 1]});
    return;
  }
  if (sx == n - 1) {
    apply({a[sx][sy], a[sx][sy + 1], a[sx - 1][sy + 1], a[sx - 1][sy]});
    for (int i = 0; i < (2); ++i)
      apply({a[sx][sy - 1], a[sx][sy], a[sx][sy + 1], a[sx - 1][sy + 1],
             a[sx - 1][sy], a[sx - 1][sy - 1]});
    for (int i = 0; i < (2); ++i)
      apply({a[sx - 1][sy - 1], a[sx - 1][sy], a[sx][sy], a[sx][sy - 1]});
    return;
  }
  printf("idx = %d   %d %d\n", idx, idx / m, idx % m);
  show();
  printf("dist = %d\n", current_dist);
  assert(0);
}
bool solve() {
  for (int x = 0; x < (n - 2); ++x)
    for (int y = 0; y < (m); ++y)
      if (!c[x][y]) {
        if (a[x][y] != ID(x, y)) solve(x, y);
        if (a[x][y] == ID(x, y)) c[x][y] = true;
        return true;
      }
  for (int y = 0; y < (m); ++y)
    for (int x = 0; x < (n); ++x)
      if (!c[x][y]) {
        if (x >= n - 2 && y >= m - 2 && (x == n - 1 || y == m - 1))
          return false;
        if (a[x][y] != ID(x, y)) solve(x, y);
        if (a[x][y] == ID(x, y)) c[x][y] = true;
        return true;
      }
  return false;
}
void apply(vector<int> p) {
  ret.push_back(p);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j) x[a[i][j]] = i, y[a[i][j]] = j;
  int c = ((int)p.size());
  for (int i = 0; i < (c); ++i)
    assert(abs(x[p[i]] - x[p[(i + 1) % c]]) +
               abs(y[p[i]] - y[p[(i + 1) % c]]) ==
           1);
  for (int i = 0; i < (c); ++i) a[x[p[(i + 1) % c]]][y[p[(i + 1) % c]]] = p[i];
}
int main() {
  std::ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) {
        cin >> a[i][j];
        --a[i][j];
      }
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) saved_a[i][j] = a[i][j];
    while (1) {
      for (int i = 0; i < (n); ++i)
        for (int j = 0; j < (m); ++j) a[i][j] = saved_a[i][j];
      for (int i = 0; i < (n); ++i)
        for (int j = 0; j < (m); ++j) c[i][j] = false;
      ret.clear();
      for (int i = 0; i < (1000); ++i) {
        int x = rand() % (n - 1);
        int y = rand() % (m - 1);
        vector<int> p;
        p.push_back(a[x][y]);
        p.push_back(a[x][y + 1]);
        p.push_back(a[x + 1][y + 1]);
        p.push_back(a[x + 1][y]);
        apply(p);
      }
      while (1) {
        if (!solve()) break;
      }
      bool ok = true;
      for (int i = 0; i < (n); ++i)
        for (int j = 0; j < (m); ++j)
          if (a[i][j] != ID(i, j)) ok = false;
      if (!ok) continue;
      printf("%d\n", ((int)ret.size()));
      for (vector<int> a : ret) {
        printf("%d", ((int)a.size()));
        for (int p : a) printf(" %d", p + 1);
        printf("\n");
      }
      break;
    }
    break;
  }
  return 0;
}