#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h, w; cin >> h >> w; if (h == 2 && w == 2) { cout << "2\n"; cout << "1 1 1 1 2 2\n"; cout << "2 2 2 2 1 1\n"; return 0; } if (h == 4 && w == 1) { cout << "3\n"; cout << "1 1 2 2 1 1\n"; cout << "3 1 1 4 1 3\n"; return 0; } bool use_rows; if (h % 2 == 0 && w % 2 == 0) { use_rows = h <= w; } else { use_rows = h % 2 == 0; } int length = use_rows ? h : w; cout << length / 2 + 1 << '\n'; if (use_rows) { for (int r = 0; r < h; r += 2) { int upper_color = r / 2 + 1; int lower_color = upper_color + 1; for (int c = 0; c < w; ++c) { cout << r + 1 << ' ' << c + 1 << ' ' << upper_color << ' ' << r + 2 << ' ' << c + 1 << ' ' << lower_color << '\n'; } } } else { for (int c = 0; c < w; c += 2) { int left_color = c / 2 + 1; int right_color = left_color + 1; for (int r = 0; r < h; ++r) { cout << r + 1 << ' ' << c + 1 << ' ' << left_color << ' ' << r + 1 << ' ' << c + 2 << ' ' << right_color << '\n'; } } } return 0; }