#include using namespace std; int main() { int X, Y; cin >> X >> Y; int n = X * Y; cout << n << " " << n << endl; for (int i = 0; i < X; ++i) cout << i + 1 << " " << (i + 1) % X + 1 << endl; for (int i = 1; i <= X * (Y - 1); ++i) cout << i << " " << i + X << endl; return 0; }