#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long a[n][n];
  for (long long i = 0; i < n - 1; i++)
    for (long long j = 0; j < n - 1; j++) a[i][j] = (i + j) % (n - 1);
  for (long long i = 0; i < n; i++)
    a[i][n - 1] = a[n - 1][i] = a[i][i], a[i][i] = 0;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      if (i != j && a[i][j] == 0) a[i][j] = n - 1;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) cout << a[i][j] << " ";
    cout << "\n";
  }
}
