#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #ifdef local #include #else #define dump(...) void(0); #endif #include #include #include namespace man { } int main() { std::cin.tie(nullptr) -> sync_with_stdio(false); using namespace std::views; int x, y; std::cin >> x >> y; const auto z = x * y; std::cout << z << ' ' << z << '\n'; for(const auto i: iota(0, x)) { for(const auto j: iota(1) | take(y - 1)) { std::cout << y * i + j << ' ' << y * i + j + 1 << '\n'; } if(i + 1 < x) { std::cout << i * y + 1 << ' ' << (i + 1) * y + 1 << '\n'; } } }