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 MAXN = 22;
int N, M;
int orr[MAXN][MAXN];
int arr[MAXN][MAXN];
vector<vector<int> > moves;
vector<int> gmove(int x, int y) {
  vector<int> res;
  res.push_back(x);
  res.push_back(y);
  res.push_back(x - 1);
  res.push_back(y);
  res.push_back(x - 1);
  res.push_back(y + 1);
  res.push_back(x);
  res.push_back(y + 1);
  res.push_back(x);
  res.push_back(y);
  res.push_back(x);
  res.push_back(y + 1);
  res.push_back(x);
  res.push_back(y - 1);
  res.push_back(x - 1);
  res.push_back(y - 1);
  res.push_back(x);
  res.push_back(y);
  res.push_back(x - 1);
  res.push_back(y + 1);
  res.push_back(x - 1);
  res.push_back(y);
  res.push_back(x - 1);
  res.push_back(y - 1);
  res.push_back(x);
  res.push_back(y - 1);
  res.push_back(x);
  res.push_back(y + 1);
  return res;
}
void op(int x, int y, int x2, int y2) {
  int ox = x, oy = y;
  bool vflip = (x2 == x + 1);
  bool xflip = (x == 0);
  if (xflip) {
    if (vflip)
      x = N - 2 - x;
    else
      x = N - 1 - x;
  }
  bool yflip = (y == 0);
  if (yflip) {
    if (vflip)
      y = M - 1 - y;
    else
      y = M - 2 - y;
  }
  if (vflip) {
    swap(x, y);
  }
  vector<int> r = gmove(x, y);
  for (int i = 0; i < r.size(); i += 2) {
    if (vflip) swap(r[i], r[i + 1]);
  }
  for (int i = 0; i < r.size(); i += 2) {
    if (xflip) r[i] = N - 1 - r[i];
  }
  for (int i = 1; i < r.size(); i += 2) {
    if (yflip) r[i] = M - 1 - r[i];
  }
  vector<int> v;
  for (int i = 0; i < 4; i++) {
    v.push_back(arr[r[2 * i]][r[2 * i + 1]]);
  }
  moves.push_back(v);
  v.clear();
  for (int i = 4; i < 8; i++) {
    v.push_back(arr[r[2 * i]][r[2 * i + 1]]);
  }
  moves.push_back(v);
  v.clear();
  for (int i = 8; i < 14; i++) {
    v.push_back(arr[r[2 * i]][r[2 * i + 1]]);
  }
  moves.push_back(v);
  swap(arr[ox][oy], arr[x2][y2]);
}
void print_moves() {
  cout << moves.size() << "\n";
  for (vector<int> v : moves) {
    cout << v.size();
    for (int x : v) cout << " " << x;
    cout << "\n";
  }
}
void gogo() {
  for (int i = 0; i < N * M; i++) {
    int rloc = i / M, cloc = i % M;
    int xloc = -1, yloc = -1;
    for (int j = 0; j < N; j++)
      for (int k = 0; k < M; k++) {
        if (arr[j][k] == i + 1) {
          xloc = j;
          yloc = k;
        }
      }
    while (yloc != cloc) {
      if (yloc < cloc) {
        op(xloc, yloc, xloc, yloc + 1);
        yloc++;
      } else {
        op(xloc, yloc - 1, xloc, yloc);
        yloc--;
      }
    }
    while (xloc != rloc) {
      assert(xloc > rloc);
      op(xloc - 1, yloc, xloc, yloc);
      xloc--;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> arr[i][j];
      orr[i][j] = arr[i][j];
    }
  }
  gogo();
  if (moves.size() * 14 / 3 > 100000) {
    moves.clear();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) arr[i][j] = orr[i][j];
    }
    for (int i = 1; i + 1 < N; i += 2) {
      for (int m = 0; m < M; m++) {
        vector<int> v;
        for (int j = 0; j < M; j++) v.push_back(arr[i][j]);
        for (int j = M - 1; j >= 0; j--) v.push_back(arr[i + 1][j]);
        int nlast = arr[i][0];
        for (int j = 0; j < M; j++) {
          swap(arr[i][j], nlast);
        }
        for (int j = M - 1; j >= 0; j--) {
          swap(arr[i + 1][j], nlast);
        }
        arr[i][0] = nlast;
        moves.push_back(v);
      }
    }
    gogo();
  }
  print_moves();
}