// #include #include using namespace std; using ll = long long; constexpr ll inf = (1LL << 61); ll dx[4] = {0, 1, 0, -1}; ll dy[4] = {-1, 0, 1, 0}; #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define REP(i, init, n) for (ll i = (ll)init; i < (ll)(n); ++i) // ll op(ll a, ll b) { return max(a, b); } // ll e() { return -inf; } int main() { ll x, y; cin >> x >> y; ll N = x * y; cout << N << " " << N << endl; ll c = 1; rep(i, x) { rep(j, y - 1) { cout << c << " " << c + 1 << endl; ++c; } ++c; } rep(i, x) { cout << y * i + 1 << " " << (y * i + y + 1) % (x * y) << endl; } }