#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 10;
int a[MAXN][MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int cnt;
  for (int i = 1; i < n; i++) {
    cnt = i;
    for (int j = 1; j < n; j++) {
      a[i][j] = cnt, cnt++;
      if (cnt > n - 1) cnt = 1;
    }
    a[i][n] = a[n][i] = a[i][i];
    a[i][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) cout << a[i][j] << " ";
    cout << endl;
  }
  return 0;
}
