#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) #define all(a) (a).begin(),(a).end() int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int X, Y; cin >> X >> Y; cout << X*Y << ' ' << X*Y << '\n'; int v = 1; rep(i, 0, X) { rep(j, 0, Y - 1) { cout << v << ' ' << v + 1 << '\n'; ++v; } ++v; } v = 1; rep(i, 0, X - 1) { cout << v << ' ' << v + Y << '\n'; v += Y; } cout << v << ' ' << 1 << '\n'; }