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;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 20;
int n, m;
int a[maxn + 5][maxn + 5];
int sum = 0;
vector<vector<int> > ans;
inline void step(int first, int second, int xd, int yd) {
  sum += 4;
  ans.push_back({a[first][second], a[first][second + yd],
                 a[first + xd][second + yd], a[first + xd][second]});
  swap(a[first][second], a[first + xd][second]);
  swap(a[first + xd][second], a[first + xd][second + yd]);
  swap(a[first + xd][second + yd], a[first][second + yd]);
}
inline void rstep(int first, int second, int xd, int yd) {
  sum += 4;
  ans.push_back({a[first][second], a[first + xd][second],
                 a[first + xd][second + yd], a[first][second + yd]});
  swap(a[first][second], a[first][second + yd]);
  swap(a[first][second + yd], a[first + xd][second + yd]);
  swap(a[first + xd][second + yd], a[first + xd][second]);
}
inline void r(int first, int _y) {
  for (int u = (0), u_end_ = (2); u < u_end_; ++u)
    for (int v = (0), v_end_ = (2); v < v_end_; ++v) {
      int xd = u ? 1 : -1;
      int yd = v ? 1 : -1;
      int second = _y;
      if (yd == -1) {
        second -= yd;
      }
      if (first + xd >= 0 && first + xd < n && second >= 0 && second < m &&
          second + 2 * yd >= 0 && second + 2 * yd < m) {
        step(first, second, xd, yd);
        step(first, second + yd, xd, yd);
        sum += 6;
        ans.push_back({a[first][second], a[first + xd][second],
                       a[first + xd][second + yd],
                       a[first + xd][second + 2 * yd],
                       a[first][second + 2 * yd], a[first][second + yd]});
        swap(a[first][second], a[first][second + yd]);
        swap(a[first][second + yd], a[first][second + 2 * yd]);
        swap(a[first][second + 2 * yd], a[first + xd][second + 2 * yd]);
        swap(a[first + xd][second + 2 * yd], a[first + xd][second + yd]);
        swap(a[first + xd][second + yd], a[first + xd][second]);
        return;
      }
    }
}
inline void c(int _x, int second) {
  for (int u = (0), u_end_ = (2); u < u_end_; ++u)
    for (int v = (0), v_end_ = (2); v < v_end_; ++v) {
      int xd = u ? 1 : -1;
      int yd = v ? 1 : -1;
      int first = _x;
      if (xd == -1) {
        first -= xd;
      }
      if (second + yd >= 0 && second + yd < m && first >= 0 && first < n &&
          first + 2 * xd >= 0 && first + 2 * xd < n) {
        rstep(first, second, xd, yd);
        rstep(first + xd, second, xd, yd);
        sum += 6;
        ans.push_back({a[first][second], a[first][second + yd],
                       a[first + xd][second + yd],
                       a[first + 2 * xd][second + yd],
                       a[first + 2 * xd][second], a[first + xd][second]});
        swap(a[first][second], a[first + xd][second]);
        swap(a[first + xd][second], a[first + 2 * xd][second]);
        swap(a[first + 2 * xd][second], a[first + 2 * xd][second + yd]);
        swap(a[first + 2 * xd][second + yd], a[first + xd][second + yd]);
        swap(a[first + xd][second + yd], a[first][second + yd]);
        return;
      }
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i)
    for (int j = (0), j_end_ = (m); j < j_end_; ++j) scanf("%d", a[i] + j);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i)
    for (int j = (0), j_end_ = (m); j < j_end_; ++j) {
      int first = i * m + j + 1;
      int curu = -1, curv = -1;
      for (int u = (0), u_end_ = (n); u < u_end_; ++u)
        for (int v = (0), v_end_ = (m); v < v_end_; ++v) {
          if (a[u][v] == first) {
            curu = u;
            curv = v;
          }
        }
      while (curv < j) {
        if (curu + 1 < n && curv + 1 < m) {
          step(curu, curv, 1, 1);
        } else
          r(curu, curv);
        ++curv;
      }
      while (curv > j) {
        if (curu + 1 < n)
          rstep(curu, curv - 1, 1, 1);
        else
          r(curu, curv - 1);
        --curv;
      }
      while (curu > i) {
        if (curv + 1 < m) {
          step(curu - 1, curv, 1, 1);
        } else
          c(curu - 1, curv);
        --curu;
      }
    }
  printf("%d\n", (int((ans).size())));
  for (auto u : ans) {
    printf("%d", (int((u).size())));
    for (auto v : u) printf(" %d", v);
    printf("\n");
  }
  fprintf(stderr, "%d\n", sum);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
    for (int j = (0), j_end_ = (m); j < j_end_; ++j)
      fprintf(stderr, "%d ", a[i][j]);
    fprintf(stderr, "\n");
  }
  return 0;
}