#include #include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; // const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, // dx[] = {0, -1, -1, -1, 0, 1, 1, 1}; struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); cerr << fixed << setprecision(10); } } iosetup; /*-------------------------------------------------*/ int main() { int n, k; cin >> n >> k; if (k == 1) { cout << "Yes\n"; FOR(i, 1, n + 1) cout << i << (i + 1 == n ? '\n' : ' '); return 0; } if (k == 2) { if (n % 4 != 0) { cout << "No\n"; return 0; } vector > ans(k); int now = 1; bool uekara = true; while (now < n) { if (uekara) { ans[0].emplace_back(now++); ans[1].emplace_back(now++); } else { ans[1].emplace_back(now++); ans[0].emplace_back(now++); } uekara = !uekara; } cout << "Yes\n"; REP(i, k) REP(j, n / k) cout << ans[i][j] << (j + 1 == n / k ? '\n' : ' '); return 0; } if (n / k == 2) { vector > ans(k); FOR(i, 1, k + 1) ans[i - 1].emplace_back(i); FOR(i, k + 1, n + 1) ans[k - 1 - (i - (k + 1))].emplace_back(i); cout << "Yes\n"; REP(i, k) cout << ans[i][0] << ' ' << ans[i][1] << '\n'; return 0; } if (n == k || k % 2 == 0) { cout << "No\n"; return 0; } vector > ans(k); for (int i = 1; i <= n;) { if (i + k * 3 - 1 == n) { REP(j, k) ans[j].emplace_back(i++); FOR(j, k / 2 + 1, k) ans[j].emplace_back(i++); REP(j, k / 2 + 1) ans[j].emplace_back(i++); } else { REP(j, k) ans[j].emplace_back(i++); for (int j = k - 1; j >= 0; --j) ans[j].emplace_back(i++); } } cout << "Yes\n"; REP(i, k) REP(j, n / k) cout << ans[i][j] << (j + 1 == n / k ? '\n' : ' '); return 0; }