#include <bits/stdc++.h>
using namespace std;
int a[100000];
int b[100000];
int main() {
  int n, m;
  cin >> n >> m;
  int count = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i] == 1 && b[j] == 1) {
        continue;
      }
      count++;
      a[i] = 1;
      b[j] = 1;
    }
  }
  cout << count << endl;
  for (int i = 1; i <= 100; i++) {
    a[i] = 0;
    b[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i] == 1 && b[j] == 1) {
        continue;
      }
      cout << i << " " << j << endl;
      a[i] = 1;
      b[j] = 1;
    }
  }
}
