#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b, i, j;
  cin >> n >> m;
  int k = 0;
  a = max(n, m);
  b = min(n, m);
  k += b;
  k += (a - 1);
  cout << k << endl;
  for (j = 1; j <= m; j++) cout << 1 << " " << j << endl;
  for (i = 2; i <= n; i++) cout << i << " " << 1 << endl;
  return 0;
}
