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;
int dis[362880];
int rex[8][4] = {{0, 0, 1, 1}, {0, 0, 1, 1}, {1, 1, 2, 2}, {1, 1, 2, 2},
                 {0, 1, 1, 0}, {0, 1, 1, 0}, {1, 2, 2, 1}, {1, 2, 2, 1}},
    rey[8][4] = {
        {0, 1, 1, 0}, {1, 2, 2, 1}, {0, 1, 1, 0}, {1, 2, 2, 1},
        {0, 0, 1, 1}, {1, 1, 2, 2}, {0, 0, 1, 1}, {1, 1, 2, 2},
};
int appr[362880], las[362880];
vector<int> trans[3][3][3][3];
int code(int* a) {
  int ret = 0;
  for (int i = 0; i < 9; i++) {
    ret = 1ll * ret * (9 - i);
    for (int j = i + 1; j < 9; j++) ret += (a[i] > a[j]);
  }
  return ret;
}
void deco(int val, int* a) {
  static bool cho[9];
  for (int i = 8; i >= 0; i--)
    a[i] = val % (9 - i), val /= 9 - i, cho[i] = false;
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++)
      if (!cho[j] && !a[i]--) {
        a[i] = j, cho[j] = true;
        break;
      }
}
void print(int* a) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) printf("%d", a[i * 3 + j]);
    puts("");
  }
  puts("");
}
void mo(int* a, int id) {
  int tmp = a[rex[id][3] * 3 + rey[id][3]];
  for (int i = 2; i >= 0; i--)
    a[rex[id][i + 1] * 3 + rey[id][i + 1]] = a[rex[id][i] * 3 + rey[id][i]];
  a[rex[id][0] * 3 + rey[id][0]] = tmp;
}
int a[9];
queue<int> q;
void bfs() {
  memset(dis, -1, sizeof(dis)), dis[0] = 0, q.push(0);
  while (!q.empty()) {
    int x = q.front(), y;
    q.pop();
    deco(x, a);
    for (int i = 0; i < 8; i++) {
      mo(a, i);
      y = code(a);
      if (dis[y] == -1) dis[y] = dis[x] + 1, las[y] = x, appr[y] = i, q.push(y);
      mo(a, i ^ 4);
    }
  }
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      for (int I = 0; I < 3; I++)
        for (int J = 0; J < 3; J++) {
          if (i == I && j == J) continue;
          for (int k = 0; k < 9; k++) a[k] = k;
          swap(a[i * 3 + j], a[I * 3 + J]);
          int x = code(a);
          while (x) trans[i][j][I][J].push_back(appr[x]), x = las[x];
          reverse(trans[i][j][I][J].begin(), trans[i][j][I][J].end());
        }
}
int n, m, b[1000];
vector<vector<int> > v;
void MOVE(vector<int> x, vector<int> y) {
  vector<int> u;
  for (int i = 0; i < 4; i++) u.push_back(b[x[i] * m + y[i]]);
  v.push_back(u);
  int tmp = b[x[3] * m + y[3]];
  for (int i = 2; i >= 0; i--) b[x[i + 1] * m + y[i + 1]] = b[x[i] * m + y[i]];
  b[x[0] * m + y[0]] = tmp;
}
void MOVE(int x, int y, int id) {
  vector<int> X(4), Y(4);
  for (int i = 0; i < 4; i++) X[i] = rex[id][i] + x, Y[i] = rey[id][i] + y;
  MOVE(X, Y);
}
void MOVE(int x, int y, int X, int Y) {
  int xx = max(0, max(x, X) - 2);
  int yy = max(0, max(y, Y) - 2);
  x -= xx, y -= yy, X -= xx, Y -= yy;
  for (auto i : trans[x][y][X][Y]) MOVE(xx, yy, i);
}
void Rightward(int& x, int& y) {
  if (x == n - 1)
    MOVE(x, y, x, y + 1);
  else
    MOVE({x, x, x + 1, x + 1}, {y, y + 1, y + 1, y});
  y++;
}
void Leftward(int& x, int& y) {
  if (x == n - 1)
    MOVE(x, y, x, y - 1);
  else
    MOVE({x, x, x + 1, x + 1}, {y, y - 1, y - 1, y});
  y--;
}
void Upward(int& x, int& y) {
  if (y == m - 1)
    MOVE(x, y, x - 1, y);
  else
    MOVE({x - 1, x - 1, x, x}, {y, y + 1, y + 1, y});
  x--;
}
int main() {
  bfs();
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &b[i * m + j]);
  for (int i = 0; i < n * m; i++) {
    int x = i / m, y = i % m, X, Y;
    for (int j = i; j < n * m; j++)
      if (b[j] == i + 1) X = j / m, Y = j % m;
    if (x == X && y == Y) continue;
    if (X == n - 1 && x < n - 2) Upward(X, Y);
    while (Y < y) Rightward(X, Y);
    while (Y > y) Leftward(X, Y);
    while (X > x) Upward(X, Y);
  }
  printf("%d\n", v.size());
  for (auto i : v) {
    printf("%d ", i.size());
    for (auto j : i) printf("%d ", j);
    puts("");
  }
  return 0;
}