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 int MAXN = 30;
const int MAXM = 30;
int N, M;
int X[MAXN][MAXM];
int cost;
vector<vector<int>> answer;
void doCycle(vector<pair<int, int>> vec) {
  vector<int> vals;
  for (auto it : vec) {
    assert(0 <= it.first && it.first < N);
    assert(0 <= it.second && it.second < M);
    vals.push_back(X[it.first][it.second]);
  }
  answer.push_back(vals);
  cost += int(vals.size());
  for (int i = 0; i < int(vec.size()); i++) {
    auto it = vec[(i + 1) % int(vec.size())];
    X[it.first][it.second] = vals[i];
  }
}
void cycleRight(int i, int j) {
  assert(0 <= i);
  assert(0 <= j);
  assert(i + 1 < N);
  assert(j + 1 < M);
  doCycle(
      vector<pair<int, int>>{{i, j}, {i, j + 1}, {i + 1, j + 1}, {i + 1, j}});
}
void cycleDown(int i, int j) {
  assert(0 <= i);
  assert(0 <= j);
  assert(i + 1 < N);
  assert(j + 1 < M);
  doCycle(
      vector<pair<int, int>>{{i, j}, {i + 1, j}, {i + 1, j + 1}, {i, j + 1}});
}
void swapBot() {
  doCycle(vector<pair<int, int>>{{N - 2, M - 3},
                                 {N - 2, M - 2},
                                 {N - 2, M - 1},
                                 {N - 1, M - 1},
                                 {N - 1, M - 2},
                                 {N - 1, M - 3}});
  cycleDown(N - 2, M - 3);
  cycleDown(N - 2, M - 2);
}
void swapRight() {
  cycleRight(N - 2, M - 2);
  swapBot();
  cycleDown(N - 2, M - 2);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> X[i][j];
      X[i][j]--;
    }
  }
  for (int di = 0; di + 2 < N; di++) {
    for (int dj = 0; dj < M; dj++) {
      int v = di * M + dj;
      int si, sj;
      for (si = 0; si < N; si++) {
        for (sj = 0; sj < M; sj++) {
          if (X[si][sj] == v) {
            goto foundSiSj;
          }
        }
      }
      assert(false);
    foundSiSj:
      assert(X[si][sj] == v);
      assert(si >= di);
      if (si == di && sj == dj) continue;
      while (sj < dj) {
        if (si == N - 1) {
          cycleDown(si - 1, sj);
        } else {
          cycleRight(si, sj);
        }
        sj++;
        assert(X[si][sj] == v);
      }
      while (sj > dj) {
        if (si == N - 1) {
          cycleRight(si - 1, sj - 1);
        } else {
          cycleDown(si, sj - 1);
        }
        sj--;
        assert(X[si][sj] == v);
      }
      assert(X[si][sj] == v);
      assert(sj == dj);
      if (dj == M - 1) {
        assert(si != di);
        assert(si > di);
        while (si > di + 2) {
          cycleDown(si - 1, sj - 1);
          si--;
          assert(X[si][sj] == v);
        }
        if (si == di + 1) {
          cycleRight(si, sj - 1);
          si++;
          assert(X[si][sj] == v);
        }
        assert(si == di + 2);
        assert(sj == dj);
        assert(X[di][dj - 1] == v - 1);
        cycleRight(di, dj - 1);
        cycleRight(di, dj - 1);
        doCycle(vector<pair<int, int>>{{di, dj - 1},
                                       {di + 1, dj - 1},
                                       {di + 2, dj - 1},
                                       {di + 2, dj},
                                       {di + 1, dj},
                                       {di, dj}});
        doCycle(vector<pair<int, int>>{{di, dj - 1},
                                       {di + 1, dj - 1},
                                       {di + 2, dj - 1},
                                       {di + 2, dj},
                                       {di + 1, dj},
                                       {di, dj}});
        assert(X[di][dj - 1] == v - 1);
        assert(X[di][dj] == v);
      } else {
        while (si > di) {
          cycleRight(si - 1, sj);
          si--;
          assert(X[si][sj] == v);
        }
        assert(si == di && sj == dj);
      }
    }
  }
  for (int dj = 0; dj + 2 < M; dj++) {
    for (int di = N - 2; di < N; di++) {
      int v = di * M + dj;
      int si, sj;
      for (si = 0; si < N; si++) {
        for (sj = 0; sj < M; sj++) {
          if (X[si][sj] == v) {
            goto foundSiSj2;
          }
        }
      }
      assert(false);
    foundSiSj2:
      assert(X[si][sj] == v);
      if (si == di && sj == dj) continue;
      if (di == N - 2) {
        if (si == N - 1) {
          if (sj == M - 1) {
            cycleDown(si - 1, sj - 1);
            si--;
            assert(X[si][sj] == v);
          } else {
            cycleRight(si - 1, sj);
            si--;
            assert(X[si][sj] == v);
          }
        }
        assert(si == N - 2);
        assert(X[si][sj] == v);
        assert(si == di);
        assert(sj >= dj);
        while (sj > dj) {
          cycleDown(si, sj - 1);
          sj--;
          assert(X[si][sj] == v);
        }
        assert(si == di && sj == dj);
      } else {
        assert(di == N - 1);
        if (sj == dj) continue;
        assert(sj > dj);
        if (si == N - 2) {
          if (sj == M - 1) {
            cycleRight(si, sj - 1);
            si++;
            assert(X[si][sj] == v);
          } else {
            cycleDown(si, sj);
            si++;
            assert(X[si][sj] == v);
          }
        }
        assert(si == N - 1);
        assert(X[si][sj] == v);
        if (sj == dj + 1) {
          cycleDown(si - 1, sj);
          sj++;
          assert(X[si][sj] == v);
        }
        while (sj > dj + 2) {
          cycleRight(si - 1, sj - 1);
          sj--;
          assert(X[si][sj] == v);
        }
        assert(X[si][sj] == v);
        assert(sj == dj + 2);
        cycleRight(di - 1, dj);
        cycleRight(di - 1, dj);
        doCycle(vector<pair<int, int>>{{di, dj},
                                       {di - 1, dj},
                                       {di - 1, dj + 1},
                                       {di - 1, dj + 2},
                                       {di, dj + 2},
                                       {di, dj + 1}});
        doCycle(vector<pair<int, int>>{{di, dj},
                                       {di - 1, dj},
                                       {di - 1, dj + 1},
                                       {di - 1, dj + 2},
                                       {di, dj + 2},
                                       {di, dj + 1}});
      }
    }
  }
  int va = (N - 2) * M + (M - 2);
  int vb = (N - 2) * M + (M - 1);
  int vc = (N - 1) * M + (M - 2);
  int vd = (N - 1) * M + (M - 1);
  while (X[N - 2][M - 2] != va) {
    cycleRight(N - 2, M - 2);
  }
  assert(X[N - 2][M - 2] == va);
  if (X[N - 1][M - 2] == vd) swapBot();
  if (X[N - 2][M - 1] == vd) swapRight();
  assert(X[N - 2][M - 2] == va);
  assert(X[N - 1][M - 1] == vd);
  if (X[N - 2][M - 1] != vb) {
    swapBot();
    swapRight();
    swapBot();
  }
  assert(X[N - 2][M - 1] == vb);
  assert(X[N - 1][M - 2] == vc);
  cerr << cost << ' ' << "moves" << '\n';
  cout << answer.size() << '\n';
  for (const auto& vec : answer) {
    cout << vec.size();
    for (int v : vec) {
      cout << ' ' << v + 1;
    }
    cout << '\n';
  }
  return 0;
}