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