#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int remainNew = n + m;
  int k = remainNew - 1;
  cout << k << "\n";
  int j = 0;
  int count = 0;
  for (int i = 0; i < min(n, m); i++) {
    cout << (i + 1) << " " << (j + 1) << "\n";
    count++;
    if (count % 2 == 0) {
      j++;
      i--;
    }
  }
  for (int i = min(n, m) + 1; i <= max(n, m); i++) {
    if (n < m)
      cout << 1 << " " << i << "\n";
    else
      cout << i << " " << 1 << "\n";
  }
}
