#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
pair<int, int> a[MAXN];
int ans = 0;
bool k[MAXN], w[MAXN];
int main() {
  int n, m;
  cin >> n >> m;
  while (n > 0) {
    for (int i = 1; i <= m; i++) {
      if (!k[n] || !w[i]) {
        ans++;
        a[ans].first = n, a[ans].second = i;
        k[n] = true;
        w[i] = true;
      }
    }
    n--;
  }
  cout << ans << endl;
  for (int i = 1; i <= ans; i++)
    cout << a[i].first << " " << a[i].second << endl;
}
