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 a[22][22];
pair<int, int> p[22 * 22];
int n, m, cnt;
vector<vector<int> > ans;
void change(vector<pair<int, int> > k) {
  int s = k.size();
  ans.push_back({}), cnt++;
  for (int i = (0); i <= (s - 1); i++) {
    ans[cnt].push_back(a[k[i].first][k[i].second]);
    p[a[k[i].first][k[i].second]] = {k[(i + 1) % s].first,
                                     k[(i + 1) % s].second};
  }
  for (int i = (s - 1); i >= (1); i--)
    swap(a[k[i].first][k[i].second], a[k[i - 1].first][k[i - 1].second]);
}
void move(int id, int dir) {
  int x = p[id].first, y = p[id].second;
  if (dir == 0 || dir == 1) {
    int _x = (x == n ? -1 : 1);
    int _y = (dir ? 1 : -1);
    change({{x, y}, {x, y + _y}, {x + _x, y + _y}, {x + _x, y}});
  }
  if (dir == 2 || dir == 3) {
    int _x = (dir == 2 ? -1 : 1);
    int _y = (y == m ? -1 : 1);
    change({{x, y}, {x + _x, y}, {x + _x, y + _y}, {x, y + _y}});
  }
}
void transfer(int id, int x, int y) {
  while (p[id].second > y) move(id, 0);
  while (p[id].second < y) move(id, 1);
  while (p[id].first > x) move(id, 2);
  while (p[id].first < x) move(id, 3);
}
void exchange1(int x, int y) {
  int _x = (x > 1 ? -1 : 1);
  int dir = (x > 1 ? 2 : 3);
  move(a[x][y - 1], dir);
  move(a[x][y - 2], dir);
  change({{x, y},
          {x + _x, y},
          {x + _x, y - 1},
          {x + _x, y - 2},
          {x, y - 2},
          {x, y - 1}});
}
void exchange2(int x, int y) {
  move(a[x][y], 2);
  move(a[x - 1][y], 2);
  change({{x, y},
          {x, y + 1},
          {x - 1, y + 1},
          {x - 2, y + 1},
          {x - 2, y},
          {x - 1, y}});
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (m); j++) cin >> a[i][j], p[a[i][j]] = {i, j};
  cnt = -1;
  for (int i = (1); i <= (n - 2); i++) {
    for (int j = (1); j <= (m - 1); j++) transfer((i - 1) * m + j, i, j);
    if (a[i][m] == i * m) continue;
    transfer(i * m, i + 1, m - 1);
    move(a[i + 1][m - 1], 2);
    exchange1(i, m);
  }
  for (int j = (1); j <= (m - 2); j++) {
    transfer((n - 1) * m + j, n, j);
    if (a[n - 1][j] == (n - 2) * m + j) continue;
    transfer((n - 2) * m + j, n, j + 1);
    move(a[n][j], 2);
    exchange2(n, j);
  }
  while (a[n - 1][m - 1] != (n - 1) * m - 1) move(a[n][m], 2);
  if (a[n][m - 1] == (n - 1) * m)
    move(a[n][m], 2), exchange1(n, m), move(a[n][m], 0), move(a[n][m], 0);
  if (a[n][m] == (n - 1) * m)
    move(a[n][m], 0), exchange1(n, m), move(a[n][m], 2);
  if (a[n][m] == n * m - 1) exchange1(n, m);
  cout << cnt + 1 << endl;
  for (int i = (0); i <= (cnt); i++) {
    cout << ans[i].size() << " ";
    for (int j : ans[i]) cout << j << " ";
    cout << endl;
  }
  return 0;
}