#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, l = 0;
  vector<pair<long long, long long> > v;
  map<long long, long long> mp, lp;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      mp[i]++;
      lp[j]++;
      if (mp[i] == 1 || lp[i] == 1) {
        v.push_back(make_pair(i, j));
        l++;
      }
    }
  }
  cout << l << endl;
  for (i = 0; i < l; i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}
