#include <bits/stdc++.h>
using namespace std;
void print(string s) {
  cout << s << endl;
  exit(0);
}
int n, m, k, ans_x[10100], ans_y[10100];
bool _map[300][300];
int st(int p, int x, int y) {
  if (!_map[y][x + 1]) return 1;
  if (!_map[y + 1][x]) return 2;
  if (!_map[y][x - 1]) return 3;
  if (!_map[y - 1][x]) return 4;
}
void nxt(int p, int& x, int& y) {
  if (p == 1) x++;
  if (p == 2) y++;
  if (p == 3) x--;
  if (p == 4) y--;
}
void solve() {
  cin >> m >> n;
  for (int(i) = 0; i < (m + 2); i++) {
    _map[0][i] = true;
    _map[n + 1][i] = true;
  }
  for (int(i) = 0; i < (n + 2); i++) {
    _map[i][0] = true;
    _map[i][m + 1] = true;
  }
  int t, x = 1, y = 1, r, h = 0;
  if (m % 2 == 0)
    r = t = 1;
  else
    r = t = 2;
  ans_x[k] = 1;
  ans_y[k++] = 1;
  for (;;) {
    if (_map[y][x - 1] && _map[y][x + 1] && _map[y - 1][x] && _map[y + 1][x])
      break;
    int c_x = x, c_y = y;
    nxt(t, c_x, c_y);
    if (_map[c_y][c_x]) {
      t = st(t, x, y);
      h = 0;
      continue;
    }
    h++;
    if (h == 2) {
      if (r == 1 && t == 3) {
        t = 4;
        h = 0;
        continue;
      }
      if (r == 2 && t == 4) {
        t = 1;
        h = 0;
        continue;
      }
    }
    x = c_x;
    y = c_y;
    _map[y][x] = true;
    ans_x[k] = x;
    ans_y[k++] = y;
  }
  if (!(x == 1 && y == 1)) {
    cout << 1 << endl << x << " " << y << " 1 1" << endl;
    ans_x[k] = 1;
    ans_y[k++] = 1;
  } else
    cout << 0 << endl;
  for (int(i) = 0; i < (k); i++) cout << ans_x[i] << " " << ans_y[i] << endl;
}
int main() {
  solve();
  return 0;
}
