#include <bits/stdc++.h>
using namespace std;
const int maxm = 2e3 + 5;
int a[maxm][maxm];
int n;
inline void solve() {
  cin >> n;
  n--;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a[i][j] = (i + j) % n + 1;
    }
  }
  for (int i = 0; i < n; i++) {
    a[i][n] = a[n][i] = a[i][i];
    a[i][i] = 0;
  }
  n++;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << a[i][j] << ' ';
    }
    cout << endl;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
