#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N, M, A[101010]; vector> ans; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> M; int b = N / 2; int a = N - b; if (M < N - 1 or 1LL * a*b < M) { printf("NO\n"); return; } int c = 1; rep(i, 0, a) A[i * 2] = c, c++; rep(i, 0, b) A[i * 2 + 1] = c, c++; // 最低限連結させる rep(i, 0, N - 1) ans.push_back({ i, i + 1 }); M -= N - 1; rep(i, 0, a) { if (M == 0) break; rep(j, 0, b) { int aa = i * 2; int bb = j * 2 + 1; if (abs(aa - bb) <= 1) continue; ans.push_back({ aa, bb }); M--; if (M == 0) break; } } printf("YES\n"); rep(i, 0, N) { if (i) printf(" "); printf("%d", A[i]); } printf("\n"); fore(p, ans) printf("%d %d\n", p.first + 1, p.second + 1); }