#include <bits/stdc++.h>
using namespace std;
int main(int agrc, const char** argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long arr1[n - 1][n - 1], arr2[n][n];
  for (long long i = 0; i < n - 1; ++i) {
    arr1[0][i] = i + 1;
  }
  for (long long i = 1; i < n - 1; ++i) {
    for (long long j = 0; j < n - 1; ++j) {
      arr1[i][j] = arr1[i - 1][(j + 1) % (n - 1)];
    }
  }
  for (long long i = 0; i < n - 1; ++i) {
    for (long long j = 0; j < n - 1; ++j) {
      arr2[i][j] = arr1[i][j];
    }
  }
  for (long long i = 0; i < n; ++i) {
    arr2[i][n - 1] = arr2[n - 1][i] = 0;
  }
  for (long long i = 0; i < n; ++i) {
    long long t0 = arr2[i][i];
    long long t1 = arr2[i][n - 1];
    swap(arr2[i][i], arr2[i][n - 1]);
    arr2[n - 1][i] = t0;
  }
  for (long long i = 0; i < n; ++i) {
    for (long long j = 0; j < n; ++j) {
      cout << arr2[i][j] << "  ";
    }
    cout << endl;
  }
}
