#include #include #include #include using std::cin; using std::cout; using std::clog; using std::vector; using std::array; using std::swap; #include using u8 = std::uint8_t; using u16 = std::uint16_t; using u32 = std::uint32_t; using u64 = std::uint64_t; using i8 = std::int8_t; using i16 = std::int16_t; using i32 = std::int32_t; using i64 = std::int64_t; u32 C; vector> ans; /* x2x3x4x5x6 _222222222 __x3x4x5x6 ___3333333 ____x4x4x4 _____44444 111111 222222 232323 333333 444444 */ void solve_1 (u32 H, u32 W) { // Wがeven C = W / 2 + 1; for (u32 h = 0; h < H; ++h) { for (u32 w = 0; w < W; w += 2) { ans.push_back(array{ h, w, w / 2, h, w + 1, w / 2 + 1 }); } } } void solve_2 (u32 H, u32 W) { // Wがeven C = 4; for (u32 w = 0; w < W; ++w) { ans.push_back(array{ 0, w, 0, 1, w, 1 }); } for (u32 h = 2; h < H - 2; ++h) { for (u32 w = 0; w < W; w += 2) { ans.push_back(array{ h, w, 1, h, w + 1, 2 }); } } for (u32 w = 0; w < W; ++w) { ans.push_back(array{ H - 2, w, 2, H - 1, w, 3 }); } } int main() { u32 H, W; cin >> H >> W; bool swapping = false; if (H > W) swap(H, W), swapping = true; if (H < 5) { if (W % 2 == 0) { solve_1(H, W); } else { swapping = !swapping; solve_1(W, H); } } else { if (W % 2 == 0) { solve_2(H, W); } else { swapping = !swapping; solve_2(W, H); } } cout << C << '\n'; for (auto& a : ans) { if (swapping) swap(a[0], a[1]), swap(a[3], a[4]); for (u32 i = 0; i < 6; ++i) { cout << a[i] + 1 << (i == 5 ? '\n' : ' '); } } return 0; }