#define _GLIBCXX_DEBUG #include using namespace std; #define rep(i, n) for (int i = 0; i < (ll)(n); i++) #define all(a) (a).begin(), (a).end() using ll = long long; const int INF32 = 2e9; const ll INF64 = 4e18; int main() { int x, y; cin >> x >> y; cout << x*y << " " << x*y << endl; for (int i = 0; i < y-1; i++) { for (int j = 1; j <= x; j++) { cout << i*x+j << " " << (i+1)*x+j << endl; } } for (int i = x*(y-1)+1; i < x*y; i++) { cout << i << " " << i+1 << endl; } cout << x*y << " " << x*(y-1)+1 << endl; return 0; }