#include using namespace std; int main() { 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 << i*y + j << ' ' << i*y+j+1 << '\n'; } } for (int i = 1; i <= x; i++) { cout << y*i << ' ' << (i == x ? y : y*(i+1)) << endl; } }