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 N = 25;
int ans_top, n, m, a[N][N];
vector<int> ans[100005];
pair<int, int> p[N * N];
void SWP(int x, int y) {
  swap(p[x], p[y]);
  swap(a[p[x].first][p[x].second], a[p[y].first][p[y].second]);
}
void insert(vector<int> v) {
  ans[++ans_top] = v;
  for (int i = (int)(v.size() - 2); i >= (int)(0); i--) SWP(v[i], v.back());
}
void ROL(int x, int y) {
  insert(vector<int>{a[x][y], a[x + 1][y], a[x + 1][y + 1], a[x][y + 1]});
}
void ROR(int x, int y) {
  insert(vector<int>{a[x][y], a[x][y + 1], a[x + 1][y + 1], a[x + 1][y]});
}
void GOL(int x, int y) { x == n ? ROR(x - 1, y - 1) : ROL(x, y - 1); }
void GOR(int x, int y) { x == n ? ROL(x - 1, y) : ROR(x, y); }
void GOU(int x, int y) { y == m ? ROL(x - 1, y - 1) : ROR(x - 1, y); }
void GOD(int x, int y) { y == m ? ROR(x, y - 1) : ROL(x, y); }
void move(int v, int tx, int ty) {
  for (; p[v].second < ty; GOR(p[v].first, p[v].second))
    ;
  for (; p[v].second > ty; GOL(p[v].first, p[v].second))
    ;
  for (; p[v].first > tx; GOU(p[v].first, p[v].second))
    ;
  for (; p[v].first < tx; GOD(p[v].first, p[v].second))
    ;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(1); j <= (int)(m); j++) {
      scanf("%d", &a[i][j]);
      p[a[i][j]] = pair<int, int>(i, j);
    }
  for (int i = (int)(1); i <= (int)(n - 2); i++) {
    for (int j = (int)(1); j <= (int)(m - 1); j++) move(i * m - m + j, i, j);
    if (p[i * m] == pair<int, int>(i, m)) continue;
    if (p[i * m].first == i + 1) GOD(p[i * m].first, p[i * m].second);
    ROR(i, m - 1);
    move(i * m, i + 1, m);
    ROL(i, m - 1);
  }
  for (int j = (int)(1); j <= (int)(m - 2); j++) {
    move((n - 2) * m + j, n - 1, j);
    if (p[n * m - m + j] == pair<int, int>(n, j)) continue;
    if (p[n * m - m + j].second == j + 1)
      GOR(p[n * m - m + j].first, p[n * m - m + j].second);
    ROL(n - 1, j);
    move(n * m - m + j, n, j + 1);
    ROR(n - 1, j);
  }
  srand(time(NULL));
  for (;;) {
    bool flg = 0;
    for (int i = (int)(1); i <= (int)(n); i++)
      for (int j = (int)(1); j <= (int)(m); j++)
        if (a[i][j] != i * m - m + j) flg = 1;
    if (!flg) break;
    int tp = rand() % 3;
    if (tp == 0) ROL(n - 1, m - 1);
    if (tp == 1) ROL(n - 1, m - 2);
    if (tp == 2)
      insert(vector<int>{a[n - 1][m - 2], a[n - 1][m - 1], a[n - 1][m], a[n][m],
                         a[n][m - 1], a[n][m - 2]});
  }
  printf("%d\n", ans_top);
  for (int i = (int)(1); i <= (int)(ans_top); i++) {
    printf("%d ", ans[i].size());
    for (auto j : ans[i]) printf("%d ", j);
    puts("");
  }
}