#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, ans;
  while (cin >> n >> m) {
    if (n == 1 && m == 1) {
      cout << 1 << endl << 1 << " " << 1 << endl;
    } else {
      long long cnt = 0;
      ans = m + n - 1;
      cout << ans << endl;
      ans--;
      for (i = 1; i <= 1; i++) {
        for (j = 1; j <= m; j++) cout << i << " " << j << endl;
      }
      for (i = 2; i <= n; i++) cout << i << " " << m << endl;
    }
  }
  return 0;
}
