#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (n == 1) {
    cout << k << endl;
    return 0;
  }
  cout << k - 1 << " " << 1 << " ";
  for (int i = 2; i < n; i++) {
    cout << 0 << " ";
  }
  cout << endl;
  int a = 0, b = n - 3;
  for (int i = 1; i < n - 1; i++) {
    int j = a, l = b;
    while (j > 0) {
      cout << 0 << " ";
      j--;
    }
    cout << 1 << " " << k - 2 << " " << 1 << " ";
    while (l > 0) {
      cout << 0 << " ";
      l--;
    }
    cout << endl;
    a++;
    b--;
  }
  for (int i = 0; i < n - 2; i++) {
    cout << 0 << " ";
  }
  cout << 1 << " " << k - 1 << " " << endl;
}
