#include #include #include using namespace std; int main() { int k, n; cin >> n >> k; if (k == n) { if (n == 1) cout << "Yes\n1\n"; else cout << "No\n"; return 0; } int d = n/k; if (k % 2 == 0 && d % 2 == 1) { cout << "No\n"; return 0; } vector ans[k]; if (d % 2 == 1) { int offset = (d-3)*k; d -= 3; for (int x = 1, y = (k+1)/2, z = k; x <= k; ) { ans[x-1].emplace_back(offset+x); ans[x-1].emplace_back(offset+k+y); ans[x-1].emplace_back(offset+2*k+z); x++; y++; z -= 2; if (y > k) { y -= k; z += k; } } } for (int i = 0; i < k; i++) { for (int j = 0; j < d/2; j++) ans[i].emplace_back(k*j+i+1); for (int j = d/2; j < d; j++) ans[i].emplace_back(k*j+k-i); } cout << "Yes\n"; for (int i = 0; i < k; i++) { for (int x : ans[i]) cout << x << ' '; cout << endl; } }