#include <bits/stdc++.h>
using namespace std;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
void initArray(T *arr, int size, T value) {
  for (int i = 0; i < size; i++) {
    arr[i] = value;
  }
}
template <class T>
T readValue(string s) {
  T result;
  istringstream sin(s);
  sin >> result;
  return result;
}
template <class T>
inline T gcd(T a, T b) {
  return (!a) ? b : gcd(b % a, a);
}
template <class T>
inline T mod(T a, T p) {
  a %= p;
  return (a < 0) ? a + p : a;
}
template <class T>
inline int numbits(T n) {
  return (!n) ? 0 : 1 + numbits(n & (n - 1));
}
template <class T>
inline T inverse(T a, T m) {
  a = mod<T>(a, m);
  return (a == 1) ? 1 : mod((1 - m * inverse(m % a, a)) / a, m);
}
template <class T>
inline bool isPrime(T a) {
  T lim = (T)sqrt((double)a);
  for (T i = 2; i < lim; i++)
    if (a % i == 0) return false;
  return true;
}
template <class T>
inline T power(T a, T p, T mod) {
  if (!p) return 1;
  T temp = power(a, p >> 1, mod);
  temp = (temp * temp) % mod;
  if (p & 1) temp = (temp * a) % mod;
  return temp;
}
void get_primes(int start, int end, vector<int> &vi) {
  int *p = new int[end + 1];
  initArray<int>(p, end + 1, 0);
  p[1] = 1;
  for (int i = 2; i <= end; i++) {
    if (!p[i]) {
      if (i >= start) vi.push_back(i);
      for (int j = 2 * i; j <= end; j += i) p[j] = 1;
    }
  }
}
bool dfs(int current, int final, int total, int *visited, int **edges,
         bool flow) {
  if (current == final) return true;
  if (visited[current]) return false;
  visited[current] = true;
  for (int i = 0; i < total; i++)
    if (edges[current][i] && dfs(i, final, total, visited, edges, flow)) {
      if (flow) {
        edges[current][i]--;
        edges[i][current]++;
      }
      return true;
    }
  return false;
}
int flow(int in, int out, int total, int **edges) {
  int result = 0;
  int *visited = new int[total];
  while (initArray<int>(visited, total, 0),
         dfs(in, out, total, visited, edges, true))
    result++;
  return result;
}
void create_set(int x, int *P, int *rank) {
  P[x] = x;
  rank[x] = 0;
}
int find_set(int x, int *P) {
  if (x != P[x]) P[x] = find_set(P[x], P);
  return P[x];
}
bool merge_sets(int x, int y, int *P, int *rank) {
  int Px = find_set(x, P);
  int Py = find_set(y, P);
  if (Px == Py) return false;
  if (rank[Px] > rank[Py])
    P[Py] = Px;
  else
    P[Px] = Py;
  if (rank[Px] == rank[Py]) rank[Py]++;
  return true;
}
int read_cum_freq(int index, int *tree) {
  int sum = 0;
  while (index) {
    sum += tree[index];
    index -= (index & -index);
  }
  return sum;
}
void upd_freq(int index, int mxIndex, int value, int *tree) {
  while (index <= mxIndex) {
    tree[index] += value;
    index += (index & -index);
  }
}
int read_freq(int index, int *tree) {
  return read_cum_freq(index, tree) - read_cum_freq(index - 1, tree);
}
void build_failure_function(const string &str, int *temp_arr) {
  temp_arr[0] = temp_arr[1] = 0;
  for (int i = 2; i <= static_cast<int>(str.size()); i++) {
    temp_arr[i] = -1;
    for (int ind = temp_arr[i - 1]; temp_arr[i] == -1; ind = temp_arr[ind]) {
      if (str[ind] == str[i - 1]) {
        temp_arr[i] = ind + 1;
      } else if (ind == 0) {
        temp_arr[i] = 0;
      }
    }
  }
}
void KMP(const string &s1, const string &s2, int *res) {
  int *temp_arr = new int[s2.size() + 1];
  build_failure_function(s2, temp_arr);
  int i = 0;
  int ind = 0;
  while (i < static_cast<int>(s1.size())) {
    if (s1[i] == s2[ind]) {
      res[i] = ++ind;
      if (res[i] == s2.size()) {
        ind = temp_arr[ind - 1];
      }
      i++;
    } else if (ind == 0) {
      res[i++] = 0;
    } else {
      ind = temp_arr[ind];
    }
  }
  delete[] temp_arr;
}
void setup(int value) {
  freopen("input.txt", "r", stdin);
  if (value) {
    freopen("output.txt", "w", stdout);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    if (m == 2) {
      std::cout << "0" << std::endl;
      std::cout << "1 1" << std::endl;
      std::cout << "1 2" << std::endl;
      std::cout << "1 1" << std::endl;
      return 0;
    }
    std::cout << "1" << std::endl;
    std::cout << "1 " << m << " 1 1" << std::endl;
    for (int i = 1; i <= m; i++) std::cout << 1 << " " << i << std::endl;
    std::cout << "1 1" << std::endl;
    return 0;
  }
  if (m == 1) {
    if (n == 2) {
      std::cout << "0" << std::endl;
      std::cout << "1 1" << std::endl;
      std::cout << "2 1" << std::endl;
      std::cout << "1 1" << std::endl;
      return 0;
    }
    std::cout << "1" << std::endl;
    std::cout << n << " 1 1 1" << std::endl;
    for (int i = 1; i <= n; i++) std::cout << i << " " << 1 << std::endl;
    std::cout << "1 1" << std::endl;
    return 0;
  }
  if ((m & 1) && (n & 1)) {
    std::cout << 1 << std::endl;
    std::cout << n << " " << m << " " << 1 << " " << 1 << std::endl;
    int r, c;
    r = c = 1;
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= n; j++) {
        if (i & 1) {
          std::cout << j << " " << i << std::endl;
        } else {
          std::cout << n + 1 - j << " " << i << std::endl;
        }
      }
    std::cout << "1 1" << std::endl;
  } else {
    std::cout << 0 << std::endl;
    std::cout << "1 1" << std::endl;
    if (m % 2 == 0) {
      for (int i = 1; i <= m; i++)
        for (int j = 2; j <= n; j++) {
          if (i & 1) {
            std::cout << j << " " << i << std::endl;
          } else {
            std::cout << n + 2 - j << " " << i << std::endl;
          }
        }
      for (int i = m; i > 0; i--) std::cout << "1 " << i << std::endl;
    } else {
      for (int i = 1; i <= n; i++)
        for (int j = 2; j <= m; j++) {
          if (i & 1) {
            std::cout << i << " " << j << std::endl;
          } else {
            std::cout << i << " " << m + 2 - j << std::endl;
          }
        }
      for (int i = n; i > 0; i--) std::cout << i << " 1" << std::endl;
    }
  }
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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;
template <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
template <class T>
void initArray(T *arr, int size, T value) {
  for (int i = 0; i < size; i++) {
    arr[i] = value;
  }
}
template <class T>
T readValue(string s) {
  T result;
  istringstream sin(s);
  sin >> result;
  return result;
}
template <class T>
inline T gcd(T a, T b) {
  return (!a) ? b : gcd(b % a, a);
}
template <class T>
inline T mod(T a, T p) {
  a %= p;
  return (a < 0) ? a + p : a;
}
template <class T>
inline int numbits(T n) {
  return (!n) ? 0 : 1 + numbits(n & (n - 1));
}
template <class T>
inline T inverse(T a, T m) {
  a = mod<T>(a, m);
  return (a == 1) ? 1 : mod((1 - m * inverse(m % a, a)) / a, m);
}
template <class T>
inline bool isPrime(T a) {
  T lim = (T)sqrt((double)a);
  for (T i = 2; i < lim; i++)
    if (a % i == 0) return false;
  return true;
}
template <class T>
inline T power(T a, T p, T mod) {
  if (!p) return 1;
  T temp = power(a, p >> 1, mod);
  temp = (temp * temp) % mod;
  if (p & 1) temp = (temp * a) % mod;
  return temp;
}
void get_primes(int start, int end, vector<int> &vi) {
  int *p = new int[end + 1];
  initArray<int>(p, end + 1, 0);
  p[1] = 1;
  for (int i = 2; i <= end; i++) {
    if (!p[i]) {
      if (i >= start) vi.push_back(i);
      for (int j = 2 * i; j <= end; j += i) p[j] = 1;
    }
  }
}
bool dfs(int current, int final, int total, int *visited, int **edges,
         bool flow) {
  if (current == final) return true;
  if (visited[current]) return false;
  visited[current] = true;
  for (int i = 0; i < total; i++)
    if (edges[current][i] && dfs(i, final, total, visited, edges, flow)) {
      if (flow) {
        edges[current][i]--;
        edges[i][current]++;
      }
      return true;
    }
  return false;
}
int flow(int in, int out, int total, int **edges) {
  int result = 0;
  int *visited = new int[total];
  while (initArray<int>(visited, total, 0),
         dfs(in, out, total, visited, edges, true))
    result++;
  return result;
}
void create_set(int x, int *P, int *rank) {
  P[x] = x;
  rank[x] = 0;
}
int find_set(int x, int *P) {
  if (x != P[x]) P[x] = find_set(P[x], P);
  return P[x];
}
bool merge_sets(int x, int y, int *P, int *rank) {
  int Px = find_set(x, P);
  int Py = find_set(y, P);
  if (Px == Py) return false;
  if (rank[Px] > rank[Py])
    P[Py] = Px;
  else
    P[Px] = Py;
  if (rank[Px] == rank[Py]) rank[Py]++;
  return true;
}
int read_cum_freq(int index, int *tree) {
  int sum = 0;
  while (index) {
    sum += tree[index];
    index -= (index & -index);
  }
  return sum;
}
void upd_freq(int index, int mxIndex, int value, int *tree) {
  while (index <= mxIndex) {
    tree[index] += value;
    index += (index & -index);
  }
}
int read_freq(int index, int *tree) {
  return read_cum_freq(index, tree) - read_cum_freq(index - 1, tree);
}
void build_failure_function(const string &str, int *temp_arr) {
  temp_arr[0] = temp_arr[1] = 0;
  for (int i = 2; i <= static_cast<int>(str.size()); i++) {
    temp_arr[i] = -1;
    for (int ind = temp_arr[i - 1]; temp_arr[i] == -1; ind = temp_arr[ind]) {
      if (str[ind] == str[i - 1]) {
        temp_arr[i] = ind + 1;
      } else if (ind == 0) {
        temp_arr[i] = 0;
      }
    }
  }
}
void KMP(const string &s1, const string &s2, int *res) {
  int *temp_arr = new int[s2.size() + 1];
  build_failure_function(s2, temp_arr);
  int i = 0;
  int ind = 0;
  while (i < static_cast<int>(s1.size())) {
    if (s1[i] == s2[ind]) {
      res[i] = ++ind;
      if (res[i] == s2.size()) {
        ind = temp_arr[ind - 1];
      }
      i++;
    } else if (ind == 0) {
      res[i++] = 0;
    } else {
      ind = temp_arr[ind];
    }
  }
  delete[] temp_arr;
}
void setup(int value) {
  freopen("input.txt", "r", stdin);
  if (value) {
    freopen("output.txt", "w", stdout);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    if (m == 2) {
      std::cout << "0" << std::endl;
      std::cout << "1 1" << std::endl;
      std::cout << "1 2" << std::endl;
      std::cout << "1 1" << std::endl;
      return 0;
    }
    std::cout << "1" << std::endl;
    std::cout << "1 " << m << " 1 1" << std::endl;
    for (int i = 1; i <= m; i++) std::cout << 1 << " " << i << std::endl;
    std::cout << "1 1" << std::endl;
    return 0;
  }
  if (m == 1) {
    if (n == 2) {
      std::cout << "0" << std::endl;
      std::cout << "1 1" << std::endl;
      std::cout << "2 1" << std::endl;
      std::cout << "1 1" << std::endl;
      return 0;
    }
    std::cout << "1" << std::endl;
    std::cout << n << " 1 1 1" << std::endl;
    for (int i = 1; i <= n; i++) std::cout << i << " " << 1 << std::endl;
    std::cout << "1 1" << std::endl;
    return 0;
  }
  if ((m & 1) && (n & 1)) {
    std::cout << 1 << std::endl;
    std::cout << n << " " << m << " " << 1 << " " << 1 << std::endl;
    int r, c;
    r = c = 1;
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= n; j++) {
        if (i & 1) {
          std::cout << j << " " << i << std::endl;
        } else {
          std::cout << n + 1 - j << " " << i << std::endl;
        }
      }
    std::cout << "1 1" << std::endl;
  } else {
    std::cout << 0 << std::endl;
    std::cout << "1 1" << std::endl;
    if (m % 2 == 0) {
      for (int i = 1; i <= m; i++)
        for (int j = 2; j <= n; j++) {
          if (i & 1) {
            std::cout << j << " " << i << std::endl;
          } else {
            std::cout << n + 2 - j << " " << i << std::endl;
          }
        }
      for (int i = m; i > 0; i--) std::cout << "1 " << i << std::endl;
    } else {
      for (int i = 1; i <= n; i++)
        for (int j = 2; j <= m; j++) {
          if (i & 1) {
            std::cout << i << " " << j << std::endl;
          } else {
            std::cout << i << " " << m + 2 - j << std::endl;
          }
        }
      for (int i = n; i > 0; i--) std::cout << i << " 1" << std::endl;
    }
  }
  return 0;
}

```