#include <bits/stdc++.h>
using namespace std;
int ma[1005][1005];
int main() {
  int N, i, j, k, p, t;
  while (cin >> N) {
    memset(ma, 0, sizeof(ma));
    for (i = 1; i <= N - 1; i++) {
      k = i;
      for (j = 1; j <= N - 1; j++) {
        ma[i][j] = k;
        k++;
        if (k == N) k = 1;
      }
    }
    for (i = 1; i <= N; i++) {
      t = ma[i][i];
      ma[i][N] = t;
      ma[N][i] = t;
      ma[i][i] = 0;
    }
    for (i = 1; i <= N; i++) {
      for (j = 1; j <= N; j++) {
        if (j != 1) cout << " ";
        cout << ma[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}
