#include <bits/stdc++.h>
using namespace std;
int n, k;
int mp[107][107];
int main() {
  scanf("%d%d", &n, &k);
  int tmp = k;
  int pos = 1;
  while (tmp) {
    mp[1][pos]++;
    pos++;
    if (pos > n) pos = 1;
    tmp--;
  }
  for (int i = 2; i <= n; ++i) {
    mp[i][n] = mp[i - 1][1];
    for (int j = 1; j <= n - 1; ++j) mp[i][j] = mp[i - 1][j + 1];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) printf("%d ", mp[i][j]);
    puts("");
  }
}
