#include using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int x, y; cin >> x >> y; cout << x * y << " " << x * y << endl; for (int i = 0; i < x; i++) { for (int j = 1; j < y - 1; j++) { cout << y * i + 1 << " " << y * i + j + 1 << endl; cout << y * i + j + 1 << " " << y * (i + 1) << endl; } } for (int i = 0; i < x; i++) { int u = y * (i + 1); int v = u + y; if (v > x * y) { v -= x * y; } cout << u << " " << v << endl; } }