#include <bits/stdc++.h>
int main() {
  int n, k, i, j, l = 0, m, d, a, b, c;
  scanf("%d%d", &n, &k);
  int arr[n][n];
  a = k - 1;
  b = 1;
  if (n == 1)
    printf("%d", k);
  else {
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) arr[i][j] = 0;
    for (i = 0; i < n; i++) {
      arr[i][i] = a;
    }
    for (i = 0; i < n - 1; i++) {
      arr[i][i + 1] = 1;
    }
    arr[n - 1][0] = 1;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        printf("%d ", arr[i][j]);
      }
      printf("\n");
    }
  }
}
