#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, val, inc;
  cin >> n >> k;
  val = k / n;
  inc = k % n;
  vector<int> v(n, val);
  for (int i = n - inc; i < n; ++i) ++v[i];
  int c;
  for (int i = 0; i < n; ++i) {
    c = 0;
    for (int j = i; c < n; ++c) {
      cout << v[(j + c) % n] << " ";
    }
    endl(cout);
  }
  return 0;
}
