#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<std::pair<int, int>> ans;
for (int t = 0; t < 2; t++) {
std::vector<std::vector<std::pair<int, int>>> a(n + m - 1);
for (int i = -m + 1; i < n; i++) {
if ((i + t) % 2) {
continue;
}
int l = std::max(-i, i);
int r = std::min(2 * n - 2 - i, 2 * m - 2 + i);
a[l].push_back({r, i});
}
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<>> q;
for (int j = 0; j < n + m - 1; j++) {
for (auto [r, i] : a[j]) {
q.push({r, i});
}
if ((j + t) % 2) {
continue;
}
while (!q.empty()) {
auto [r, i] = q.top();
q.pop();
if (r < j) {
continue;
}
int x = (i + j) / 2 + 1;
int y = (j - i) / 2 + 1;
ans.push_back({x, y});
break;
}
}
}
std::cout << ans.size() << "\n";
for (auto [x, y] : ans) {
std::cout << x << " " << y << "\n";
}
return 0;
}