#include <bits/stdc++.h>
using namespace std;
void print(int n, int m, int f) {
  cout << "0\n";
  cout << "1 1" << endl;
  int flag = 0, i, j;
  for (i = 1; i <= n; i++) {
    if (flag) {
      for (j = m; j >= 2; j--) {
        if (f)
          cout << i << " " << j << endl;
        else
          cout << j << " " << i << endl;
      }
      flag = 0;
    } else {
      for (j = 2; j <= m; j++) {
        if (f)
          cout << i << " " << j << endl;
        else
          cout << j << " " << i << endl;
      }
      flag = 1;
    }
  }
  for (i = n; i >= 1; i--) {
    if (f)
      cout << i << " " << 1 << endl;
    else
      cout << 1 << " " << i << endl;
  }
}
int main() {
  int n, m, i, j;
  cin >> n >> m;
  if (n == 1 && m != 2 || m == 1 && n != 2) {
    if (n == 1 && m == 1)
      cout << "1 1\n"
           << "1 1\n";
    else {
      cout << "1" << endl;
      cout << n << " " << m << " 1 1" << endl;
      if (n == 1) {
        for (i = 1; i <= m; i++) cout << 1 << " " << i << endl;
        cout << "1 1\n";
      } else {
        for (i = 1; i <= n; i++) cout << i << " " << 1 << endl;
        cout << "1 1\n";
      }
    }
  } else if (n % 2 == 0 || m % 2 == 0) {
    if (n % 2 == 0)
      print(n, m, 1);
    else
      print(m, n, 0);
  } else {
    cout << "1" << endl;
    cout << n << " " << m << " 1 1" << endl;
    int flag = 0;
    for (i = 1; i <= n; i++) {
      if (flag) {
        for (j = m; j >= 1; j--) cout << i << " " << j << endl;
        flag = 0;
      } else {
        for (j = 1; j <= m; j++) cout << i << " " << j << endl;
        flag = 1;
      }
    }
    cout << "1 1\n";
  }
  return 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

The territory of Berland is represented by a rectangular field n × m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the king decided to travel through the whole country and return back to the capital, having visited every square (except the capital) exactly one time. The king must visit the capital exactly two times, at the very beginning and at the very end of his journey. The king can only move to the side-neighboring squares. However, the royal advise said that the King possibly will not be able to do it. But there is a way out — one can build the system of one way teleporters between some squares so that the king could fulfill his plan. No more than one teleporter can be installed on one square, every teleporter can be used any number of times, however every time it is used, it transports to the same given for any single teleporter square. When the king reaches a square with an installed teleporter he chooses himself whether he is or is not going to use the teleport. What minimum number of teleporters should be installed for the king to complete the journey? You should also compose the journey path route for the king.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 100, 2 ≤  n · m) — the field size. The upper left square has coordinates (1, 1), and the lower right square has coordinates of (n, m).

Output

On the first line output integer k — the minimum number of teleporters. Then output k lines each containing 4 integers x1 y1 x2 y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — the coordinates of the square where the teleporter is installed (x1, y1), and the coordinates of the square where the teleporter leads (x2, y2).

Then print nm + 1 lines containing 2 numbers each — the coordinates of the squares in the order in which they are visited by the king. The travel path must start and end at (1, 1). The king can move to side-neighboring squares and to the squares where a teleporter leads. Besides, he also should visit the capital exactly two times and he should visit other squares exactly one time.

Examples

Input

2 2


Output

0
1 1
1 2
2 2
2 1
1 1


Input

3 3


Output

1
3 3 1 1
1 1
1 2
1 3
2 3
2 2
2 1
3 1
3 2
3 3
1 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void print(int n, int m, int f) {
  cout << "0\n";
  cout << "1 1" << endl;
  int flag = 0, i, j;
  for (i = 1; i <= n; i++) {
    if (flag) {
      for (j = m; j >= 2; j--) {
        if (f)
          cout << i << " " << j << endl;
        else
          cout << j << " " << i << endl;
      }
      flag = 0;
    } else {
      for (j = 2; j <= m; j++) {
        if (f)
          cout << i << " " << j << endl;
        else
          cout << j << " " << i << endl;
      }
      flag = 1;
    }
  }
  for (i = n; i >= 1; i--) {
    if (f)
      cout << i << " " << 1 << endl;
    else
      cout << 1 << " " << i << endl;
  }
}
int main() {
  int n, m, i, j;
  cin >> n >> m;
  if (n == 1 && m != 2 || m == 1 && n != 2) {
    if (n == 1 && m == 1)
      cout << "1 1\n"
           << "1 1\n";
    else {
      cout << "1" << endl;
      cout << n << " " << m << " 1 1" << endl;
      if (n == 1) {
        for (i = 1; i <= m; i++) cout << 1 << " " << i << endl;
        cout << "1 1\n";
      } else {
        for (i = 1; i <= n; i++) cout << i << " " << 1 << endl;
        cout << "1 1\n";
      }
    }
  } else if (n % 2 == 0 || m % 2 == 0) {
    if (n % 2 == 0)
      print(n, m, 1);
    else
      print(m, n, 0);
  } else {
    cout << "1" << endl;
    cout << n << " " << m << " 1 1" << endl;
    int flag = 0;
    for (i = 1; i <= n; i++) {
      if (flag) {
        for (j = m; j >= 1; j--) cout << i << " " << j << endl;
        flag = 0;
      } else {
        for (j = 1; j <= m; j++) cout << i << " " << j << endl;
        flag = 1;
      }
    }
    cout << "1 1\n";
  }
  return 0;
}

```