#include #include using namespace std; int N, K; vector make(int n, int v) { vector ret; int s = 0, e = n - 1; for (int i = 0; i < n; i++){ if (v >= e - s){ v -= e - s; ret.push_back(e); e--; } else{ ret.push_back(s); s++; } } return ret; } int A[1010][1010]; int main() { scanf ("%d %d", &N, &K); int L = N * (N - 1); if (K > L){ puts("No"); return 0; } bool m = 0; if (K >= L / 2){ K -= L / 2; m = 1; } vector v = make(N, K); for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++) A[i][j] = j; for (int k = 0; k < v[i]; k++) swap(A[i][k], A[i][k + 1]); } for (int i = 0; i < N; i++){ int p = m ? (N - i) * 10000 : (i + 1) * 10000; for (int j = 0; j < N; j++) A[i][j] += p; } puts("Yes"); for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++) printf ("%d%c", A[i][j], j + 1 < N ? ' ' : '\n'); } return 0; }