#include <bits/stdc++.h>
int main() {
  int n, m, k, i;
  scanf("%d %d", &n, &m);
  k = m + n - 1;
  printf("%d\n", k);
  for (i = 1; i <= m; i++) printf("1 %d\n", i);
  for (i = 2; i <= n; i++) printf("%d %d\n", i, m);
  return 0;
}
