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.
#include <bits/stdc++.h>
using namespace std;
const int N = 30;
struct nd {
  int x, y;
};
nd operator+(nd a, nd b) { return {a.x + b.x, a.y + b.y}; }
nd operator-(nd a, nd b) { return {a.x - b.x, a.y - b.y}; }
nd rt(nd a) { return {a.y, -a.x}; }
int n, m, a[N][N];
int in(nd a) { return a.x >= 1 && a.x <= n && a.y >= 1 && a.y <= m; }
vector<vector<int>> ans;
void add(vector<nd> v) {
  vector<int> c;
  for (auto x : v) c.push_back(a[x.x][x.y]);
  ans.push_back(c);
  int s = v.size();
  int t = a[v.back().x][v.back().y];
  for (int i = s - 2; i >= 0; i--)
    a[v[i + 1].x][v[i + 1].y] = a[v[i].x][v[i].y];
  a[v[0].x][v[0].y] = t;
}
void ch1(nd a, nd b, nd d) {
  nd c = b + b - a, e = b + d - a, f = c + e - b;
  add({a, b, e, d});
  add({b, c, f, e});
  add({a, d, e, f, c, b});
}
void ch(nd a, nd b) {
  nd c = b + b - a;
  if (!in(c)) swap(a, b);
  nd d = a + rt(a - b);
  if (!in(d)) d = a - rt(a - b);
  ch1(a, b, d);
}
void sol(int d) {
  nd q = {(d - 1) / m + 1, (d - 1) % m + 1}, p;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == d) p = {i, j};
  while (p.y > q.y) {
    if (p.x != q.x)
      add({p, p + (nd){0, -1}, p + (nd){-1, -1}, p + (nd){-1, 0}});
    else if (p.x != n)
      add({p, p + (nd){0, -1}, p + (nd){1, -1}, p + (nd){1, 0}});
    else
      ch(p, p + (nd){0, -1});
    p.y--;
  }
  while (p.y < q.y) {
    if (p.x != q.x + 1)
      add({p, p + (nd){0, 1}, p + (nd){-1, 1}, p + (nd){-1, 0}});
    else if (p.x != n)
      add({p, p + (nd){0, 1}, p + (nd){1, 1}, p + (nd){1, 0}});
    else
      ch(p, p + (nd){0, 1});
    p.y++;
  }
  while (p.x > q.x) {
    if (p.y != m)
      add({p, p + (nd){-1, 0}, p + (nd){-1, 1}, p + (nd){0, 1}});
    else
      ch(p, p + (nd){-1, 0});
    p.x--;
  }
}
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 * m; i++) sol(i);
  printf("%d\n", ans.size());
  for (auto i : ans) {
    printf("%d ", i.size());
    for (auto j : i) printf("%d ", j);
    puts("");
  }
  return 0;
}
