#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int> > ans;
  int n, m;
  cin >> n >> m;
  int j = 1, i = 1;
  int flag = 0;
  int boyo[1000] = {0};
  int girlo[1000] = {0};
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (boyo[i] == 0 || girlo[j] == 0) {
        ans.push_back(make_pair(i, j));
        boyo[i] = 1;
        girlo[j] = 1;
      }
    }
  }
  cout << ans.size() << endl;
  for (int q = 0; q < ans.size(); q++) {
    cout << ans[q].first << " " << ans[q].second << endl;
  }
  return 0;
}
