#include <bits/stdc++.h>
using namespace std;
unsigned long long mod = 1000000007;
template <class T1>
void deb(T1 e1) {
  cout << e1 << "\n";
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << "\n";
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << "\n";
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << "\n";
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << "\n";
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << "\n";
}
int main() {
  int nob, nog, dancing_jodis = 0;
  cin >> nob >> nog;
  vector<pair<int, int> > store;
  int max_gender = max(nob, nog);
  int min_gender = min(nob, nog);
  for (int gender = 1; gender <= min_gender; gender++, dancing_jodis++)
    (nob >= nog) ? store.push_back(make_pair(1, gender))
                 : store.push_back(make_pair(gender, 1));
  for (int gender = 2; gender <= max_gender; gender++, dancing_jodis++)
    (nob >= nog) ? store.push_back(make_pair(gender, 1))
                 : store.push_back(make_pair(1, gender));
  cout << dancing_jodis << "\n";
  for (int jodi = 0; jodi < int((store).size()); jodi++)
    cout << store[jodi].first << " " << store[jodi].second << "\n";
  return 0;
}
