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;
vector<vector<int> > arr;
vector<vector<int> > moves;
vector<vector<pair<int, int> > > flip(vector<vector<pair<int, int> > > p) {
  vector<vector<pair<int, int> > > q;
  for (vector<pair<int, int> > x : p) {
    vector<pair<int, int> > y;
    for (auto a : x) {
      y.push_back({a.second, a.first});
    }
    q.push_back(y);
  }
  return q;
}
vector<vector<pair<int, int> > > get_swap(int x1, int y1, int x2, int y2) {
  assert(abs(x1 - x2) + abs(y1 - y2) == 1);
  if (x1 > x2) swap(x1, x2);
  if (y1 > y2) swap(y1, y2);
  if (x1 == x2) return flip(get_swap(y1, x1, y2, x2));
  vector<vector<pair<int, int> > > ans;
  int yz = y1 - 1;
  if (yz < 0) yz = y1 + 1;
  if (x1 == 0) {
    ans.push_back(
        {{x1, y1}, {x2, y1}, {x2 + 1, y1}, {x2 + 1, yz}, {x2, yz}, {x1, yz}});
    ans.push_back({{x2, yz}, {x2 + 1, yz}, {x2 + 1, y1}, {x2, y1}});
    ans.push_back({{x1, yz}, {x2, yz}, {x2, y1}, {x1, y1}});
  } else {
    ans.push_back(
        {{x2, y1}, {x1, y1}, {x1 - 1, y1}, {x1 - 1, yz}, {x1, yz}, {x2, yz}});
    ans.push_back({{x1, yz}, {x1 - 1, yz}, {x1 - 1, y1}, {x1, y1}});
    ans.push_back({{x2, yz}, {x1, yz}, {x1, y1}, {x2, y1}});
  }
  return ans;
}
vector<vector<pair<int, int> > > get_move(int x1, int y1, int x2, int y2,
                                          int dim) {
  assert(abs(x1 - x2) + abs(y1 - y2) == 1);
  if (x1 == x2) return flip(get_move(y1, x1, y2, x2, arr.size()));
  vector<vector<pair<int, int> > > ans;
  int yz = y1 + 1;
  if (yz >= dim) yz = y1 - 1;
  ans.push_back({{x1, y1}, {x2, y1}, {x2, yz}, {x1, yz}});
  return ans;
}
void do_moves(vector<vector<pair<int, int> > > g) {
  for (vector<pair<int, int> > a : g) {
    vector<int> b;
    for (int p = 0; p < a.size(); p++) {
      b.push_back(arr[a[p].first][a[p].second]);
    }
    moves.push_back(b);
    int r = arr[a.back().first][a.back().second];
    for (int p = a.size() - 1; p > 0; p--) {
      arr[a[p].first][a[p].second] = arr[a[p - 1].first][a[p - 1].second];
    }
    arr[a[0].first][a[0].second] = r;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  arr.resize(n, vector<int>(m, -1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int num = 1 + i * m + j;
      int x = -1;
      int y = -1;
      for (int a = 0; a < n; a++) {
        for (int b = 0; b < m; b++) {
          if (arr[a][b] == num) {
            x = a;
            y = b;
          }
        }
      }
      assert(x >= i);
      if (x == i) assert(y >= j);
      while (y < j) {
        if (x == n - 1 && x <= i + 1) {
          do_moves(get_swap(x, y, x, y + 1));
        } else {
          do_moves(get_move(x, y, x, y + 1, m));
        }
        y++;
        assert(arr[x][y] == num);
      }
      while (y > j) {
        if (x == n - 1 && x <= i + 1) {
          do_moves(get_swap(x, y, x, y - 1));
        } else {
          do_moves(get_move(x, y, x, y - 1, m));
        }
        y--;
        assert(arr[x][y] == num);
      }
      while (x > i + 1) {
        do_moves(get_move(x, y, x - 1, y, m));
        x--;
        assert(arr[x][y] == num);
      }
      while (x > i) {
        do_moves(get_swap(x, y, x - 1, y));
        x--;
        assert(arr[x][y] == num);
      }
    }
  }
  cout << moves.size() << '\n';
  for (int i = 0; i < moves.size(); i++) {
    cout << moves[i].size();
    for (int a : moves[i]) {
      cout << " " << a;
    }
    cout << '\n';
  }
}