#include using namespace std; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; int main() { int N, K; cin >> N >> K; vector mat(N, vector(N)); int i = 0, j = 0; while (i < N and j < N) { int a = N - 1 - i + N - 1 - j; if (i == N - 2 and j == N - 2 and K == 1) { mat[i][j] = mat[i + 1][j] = mat[i + 1][j + 1] = 1; i += 2, j += 2, K -= 1; } else if (a <= K) { K -= a; mat[i][j] = 1; i++, j++; } else { if (i < j) i++; else j++; } } if (K) { puts("No"); } else { cout << "Yes" << '\n'; for (auto vec : mat) { for (auto x : vec) cout << x << ' '; cout << '\n'; } } }