#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int k = ri(); if (n == 2 && k == 1) { puts("Yes\n0 1\n2 2"); return 0; } if (k > n * (n - 1)) { puts("No"); return 0; } int big = std::min(k, 2 * (n - 1)); if ((k & 1) && !(big & 1)) big--; k = (k - big) >> 1; n--; int a[n]; std::iota(a, a + n, 0); int cur = n - 1, cnt = 0; while (k && k >= cur) k -= cur, cur--, cnt++; std::rotate(a, a + cnt, a + n); std::reverse(a + n - cnt, a + n); if (k) std::rotate(a, a + 1, a + k + 1); n++; int left = big / 2; int right = big - left; std::vector > res(n, std::vector (n)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) res[i][j] = a[i - (i >= left)] != j - (j >= right); for (int i = 0; i < n; i++) res[left][i] = res[i][right] = 2; if (right == n - 1) for (auto &i : res) for (auto &j : i) j = j == 2 ? 0 : j + 1; puts("Yes"); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j) printf(" "); printf("%d", res[i][j]); } puts(""); } return 0; }