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 inf = 1e9;
const long long Inf = 1e18;
const int N = 30;
const int mod = 0;
int gi() {
  int first = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') first = first * 10 + ch - '0', ch = getchar();
  return first * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
int n, m, g[N][N];
vector<vector<int>> ans;
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(pair<int, int> a, pair<int, int> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
pair<int, int> rotate(pair<int, int> a) {
  return make_pair(a.second, -a.first);
}
void rot_cycle(vector<pair<int, int>> v) {
  vector<int> w;
  for (pair<int, int> p : v) w.push_back(g[p.first][p.second]);
  ans.push_back(w);
  int pre = g[v.back().first][v.back().second];
  for (int i = int(v.size()) - 1; i; i--)
    g[v[i].first][v[i].second] = g[v[i - 1].first][v[i - 1].second];
  g[v[0].first][v[0].second] = pre;
}
int in(pair<int, int> p) {
  return 1 <= p.first && p.first <= n && 1 <= p.second && p.second <= m;
}
void ex_swap(pair<int, int> a, pair<int, int> b, pair<int, int> d) {
  pair<int, int> c = b + b - a, e = b + d - a, f = c + d - a;
  rot_cycle({a, b, e, d});
  rot_cycle({b, c, f, e});
  rot_cycle({a, d, e, f, c, b});
}
void _swap(pair<int, int> a, pair<int, int> b) {
  pair<int, int> c = b + b - a;
  if (!in(c)) swap(a, b);
  pair<int, int> v = rotate(a - b), d = a + v;
  if (!in(d)) d = a - v;
  ex_swap(a, b, d);
}
void move(int s) {
  pair<int, int> to = make_pair((s - 1) / m + 1, (s - 1) % m + 1), fr;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (g[i][j] == s) fr = make_pair(i, j);
  while (fr.second > to.second) {
    if (fr.first + 1 <= n)
      rot_cycle({fr, fr + make_pair(0, -1), fr + make_pair(1, -1),
                 fr + make_pair(1, 0)});
    else if (fr.first - 1 > to.first)
      rot_cycle({fr, fr + make_pair(0, -1), fr + make_pair(-1, -1),
                 fr + make_pair(-1, 0)});
    else
      _swap(fr, fr + make_pair(0, -1));
    --fr.second;
  }
  while (fr.second < to.second) {
    if (fr.first + 1 <= n)
      rot_cycle({fr, fr + make_pair(0, 1), fr + make_pair(1, 1),
                 fr + make_pair(1, 0)});
    else if (fr.first - 1 > to.first)
      rot_cycle({fr, fr + make_pair(0, 1), fr + make_pair(-1, 1),
                 fr + make_pair(-1, 0)});
    else
      _swap(fr, fr + make_pair(0, 1));
    ++fr.second;
  }
  while (fr.first > to.first) {
    if (fr.second + 1 <= m)
      rot_cycle({fr, fr + make_pair(-1, 0), fr + make_pair(-1, 1),
                 fr + make_pair(0, 1)});
    else
      _swap(fr, fr + make_pair(-1, 0));
    --fr.first;
  }
}
int main() {
  n = gi(), m = gi();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) g[i][j] = gi();
  for (int i = 1; i <= n * m; i++) move(i);
  printf("%d\n", int(ans.size()));
  for (auto first : ans) {
    printf("%d ", int(first.size()));
    for (auto second : first) printf("%d ", second);
    puts("");
  }
  return 0;
}