#include #include using namespace std; typedef long long ll; void output(vector> &v){ for(int i = 0; i < v[0].size(); i++){ for(int j = 0; j < v.size(); j++){ cout << v[j][i] << " \n"[j==v.size()-1]; } } } int main(){ int n, k; cin >> n >> k; if(n/k%2 == 0){ cout << "Yes" << endl; vector> ans(n/k, vector(k)); for(int i = 0; i < n/k; i++){ int from = i*k+1; for(int j = 0; j < k; j++){ if(i%2) ans[i][j] = from+j; else ans[i][j] = from+(k-1-j); } } output(ans); }else{ int t; for(t = 1; t*k <= n/k; t++){ if((n/k-k*t)%2 == 0) break; } if(t*k > n/k){ cout << "No" << endl; return 0; } cout << "Yes" << endl; vector> ans(n/k, vector(k)); for(int i = 0; i < t*k; i++){ int from = i*k+1; for(int j = 0; j < k; j++){ ans[i][(i%k+j)%k] = from+j; } } for(int i = t*k; i < n/k; i++){ int from = i*k+1; for(int j = 0; j < k; j++){ if(i%2) ans[i][j] = from+j; else ans[i][j] = from+(k-1-j); } } output(ans); } return 0; }