#include #include using namespace std; typedef long long ll; int main(){ int n, k; cin >> n >> k; if(n/k%2 == 0){ cout << "Yes" << endl; for(int i = 0; i < n/k; i++){ int from = i*k+1; for(int j = 0; j < k; j++){ if(i%2) cout << from+j; else cout << from+(k-1-j); cout << " \n"[j==k-1]; } } }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; for(int i = 0; i < t*k; i++){ vector v(k); int from = i*k+1; for(int j = 0; j < k; j++){ v[(i%k+j)%k] = from+j; } for(int j = 0; j < k; j++){ cout << v[j] << " \n"[j==k-1]; } } for(int i = t*k; i < n/k; i++){ int from = i*k+1; for(int j = 0; j < k; j++){ if(i%2) cout << from+j; else cout << from+(k-1-j); cout << " \n"[j==k-1]; } } } return 0; }