#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pairs;
  int hash_boys[n + 1], hash_girls[m + 1];
  memset(hash_boys, 0, sizeof(hash_boys));
  memset(hash_girls, 0, sizeof(hash_girls));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (hash_boys[i] && hash_girls[j]) continue;
      pairs.push_back({i, j});
      hash_boys[i] = 1;
      hash_girls[j] = 1;
    }
  }
  cout << pairs.size() << "\n";
  for (auto p : pairs) cout << p.first << " " << p.second << "\n";
  return 0;
}
