#include #include #include #include using namespace std; using namespace atcoder; using ll = long long; //#define endl "\n"; int randInt(int L, int R){ return rand() % (R - L + 1) + L; } set st[250009]; int main(){ ll X, Y; cin >> X >> Y; srand(time(NULL)); //次数が3の頂点間でX本辺を張る for(int i = 1; i <= X; i++){ ll p1, p2; while(1){ p1 = randInt(1, X); p2 = randInt(1, X); if(p1 == p2) continue; if(p1 > p2) swap(p1, p2); if(st[p1].size() >= 3) continue; if(st[p2].size() >= 3) continue; if(st[p1].find(p2) == st[p1].end()) break; } st[p1].insert(p2); st[p2].insert(p1); } //頂点1~Xから3-次数本、長さY-1の腕を生やす int idx = X; for(int i = 1; i <= X; i++){ for(int j = (int)st[i].size() + 1; j <= 3; j++){ int pre = i; for(int k = 1; k <= Y - 1; k++){ idx++; st[pre].insert(idx); st[idx].insert(pre); pre = idx; } } } vector> ret; for(int i = 1; i <= X * Y; i++){ for(auto itr = st[i].begin(); itr != st[i].end(); ++itr){ if(i < *itr){ ret.push_back({i, *itr}); } } } cout << X * Y << " " << ret.size() << endl; for(auto[a, b]: ret) cout << a << " " << b << endl; return 0; }