#include int main() { int x, y; std::cin >> x >> y; std::cout << x * y << " " << x * y << std::endl; int count = 1; for (int i = 1; i <= x; ++i) { if (i != x) std::cout << i << " " << i + 1 << std::endl; else std::cout << i << " " << 1 << std::endl; count++; } for (int i = 1; i <= x; ++i) { for (int j = 1; j < y; ++j) { if (j == 1) std::cout << i << " " << count << std::endl; else std::cout << count - 1 << " " << count << std::endl; count++; } } }