#include <bits/stdc++.h>
using namespace std;
long long mod = (int)1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > v;
  map<int, int> m1, m2;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if ((m1.find(i) == m1.end()) or (m2.find(j) == m2.end()))
        m1[i]++, m2[j]++, v.push_back(make_pair(i, j));
    }
  }
  cout << (int)v.size() << "\n";
  for (int i = 0; i < (int)v.size(); i++)
    cout << v[i].first << " " << v[i].second << "\n";
  scanf("\n");
  return 0;
}
