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 Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
int n, m;
int a[22][22];
vector<vector<int> > vs;
void inline doit(const vector<pair<int, int> > vi) {
  int vt = a[vi.back().first][vi.back().second];
  vector<int> res;
  for (int i = 0; i < (((int)(vi).size())); ++i) {
    res.push_back(a[vi[i].first][vi[i].second]);
    swap(a[vi[i].first][vi[i].second], vt);
  }
  vs.push_back(res);
}
void inline movl(int x, int y) {
  doit({{x, y},
        {x, y - 1},
        {x == n ? x - 1 : x + 1, y - 1},
        {x == n ? x - 1 : x + 1, y}});
}
void inline movr(int x, int y) {
  doit({{x, y},
        {x, y + 1},
        {x == n ? x - 1 : x + 1, y + 1},
        {x == n ? x - 1 : x + 1, y}});
}
void inline movu(int x, int y) {
  doit({{x, y},
        {x - 1, y},
        {x - 1, y == m ? y - 1 : y + 1},
        {x, y == m ? y - 1 : y + 1}});
}
void inline movd(int x, int y) {
  doit({{x, y},
        {x + 1, y},
        {x + 1, y == m ? y - 1 : y + 1},
        {x, y == m ? y - 1 : y + 1}});
}
void inline mov2(int x, int y) {
  if (x != n - 1) {
    movd(x, y);
    movd(x + 1, y);
    movl(x, y + 1);
    movu(x + 2, y);
    movu(x + 1, y);
  } else {
    movr(x, y);
    movr(x, y + 1);
    movu(x + 1, y);
    movl(x, y + 2);
    movl(x, y + 1);
  }
}
int inline should(int x, int y) { return (x - 1) * m + y; }
pair<int, int> inline findpos(int val) {
  for (int i = 1; i <= (n); ++i)
    for (int j = 1; j <= (m); ++j)
      if (a[i][j] == val) return make_pair(i, j);
  return make_pair(-1, -1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= (n); ++i)
    for (int j = 1; j <= (m); ++j) scanf("%d", a[i] + j);
  for (int i = 1; i <= (n - 2); ++i) {
    for (int j = 1; j <= (m - 1); ++j) {
      int x, y;
      tie(x, y) = findpos(should(i, j));
      while (y < j) movr(x, y++);
      while (y > j) movl(x, y--);
      while (x > i) movu(x--, y);
    }
    int x, y;
    tie(x, y) = findpos(should(i, m));
    if (x == i && y == m) continue;
    while (y < m) movr(x, y++);
    while (x > i + 1) movu(x--, y);
    mov2(i, m - 1);
  }
  for (int j = 1; j <= (m - 2); ++j) {
    int x2, y2;
    tie(x2, y2) = findpos(should(n, j));
    if (x2 == n - 1) movd(x2++, y2);
    while (y2 > j) movl(x2, y2--);
    int x1, y1;
    tie(x1, y1) = findpos(should(n - 1, j));
    if (x1 == n - 1 && y1 == j) continue;
    if (x1 == n) movu(x1--, y1);
    while (y1 > j) movl(x1, y1--);
    mov2(n - 1, j);
  }
  auto swap3 = [&](int x1) {
    int x2 = 2 * n - 1 - x1;
    movl(x1, m);
    movl(x1, m - 1);
    doit(
        {{x1, m - 2}, {x1, m - 1}, {x1, m}, {x2, m}, {x2, m - 1}, {x2, m - 2}});
  };
  if (abs(a[n - 1][m - 1] - a[n][m]) == 1) swap3(n);
  if (abs(a[n - 1][m] - a[n][m]) == 1) {
    if (a[n - 1][m] < a[n - 1][m - 1])
      movu(n, m);
    else
      movd(n - 1, m);
  } else {
    if (a[n - 1][m] > a[n][m]) movu(n, m), movu(n, m);
  }
  if (a[n - 1][m] < a[n - 1][m - 1]) swap3(n - 1);
  if (a[n][m] < a[n][m - 1]) swap3(n);
  printf("%d\n", ((int)(vs).size()));
  for (auto &v : (vs)) {
    printf("%d", ((int)(v).size()));
    for (auto &it : (v)) printf(" %d", it);
    puts("");
  }
  return 0;
}