#include <bits/stdc++.h>
using namespace std;
struct node {
  int b, g;
};
int main(void) {
  int n, m;
  cin >> n >> m;
  int total = 0;
  vector<node> output;
  int i;
  int max = n;
  if (n < m) max = m;
  for (i = 1; i <= max; i++) {
    node n;
    if (max == m) {
      n.b = 1;
      n.g = i;
    } else {
      n.b = i;
      n.g = 1;
    }
    output.push_back(n);
    total++;
  }
  if (n < m)
    max = n;
  else
    max = m;
  for (i = 2; i <= max; i++) {
    node n;
    n.b = i;
    n.g = i;
    output.push_back(n);
    total++;
  }
  cout << total << endl;
  for (int i = 0; i < output.size(); i++) {
    cout << output[i].b << " " << output[i].g << endl;
  }
  return 0;
}
