# writer解(リベンジ1+1+1回目) # PEP8なにもわからん # オタクくんさぁ......writer解何回も間違えるなよ...... n, k = map(int, input().split()) if k > n*(n-1): print("No") exit() if k == 1: print("No") exit() ans = [n*[0] for _ in range(n)] if k >= 2*(n-1): q = [] for i in range(n): ans[i][i] = 1 for i in range(n-2, 0, -1): for j in range(i-1, -1, -1): q.append((i, j)) q.append((j, i)) for i in range(n*(n-1)-k): ans[q[i][0]][q[i][1]] = 1 elif k > 1: ans[n-1-k//2][n-1-(0--k//2)] = 1 print("Yes") for i in ans: print(*i)