#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1002;
int N, pt;
int A[MaxN][MaxN];
int main() {
  cin >> N;
  for (int i = 0; i < N - 1; ++i)
    for (int j = 0; j < N - 1; ++j) A[i][j] = 1 + (i + j) % (N - 1);
  for (int i = 0; i < N; ++i) {
    A[i][N - 1] = A[N - 1][i] = A[i][i];
    A[i][i] = 0;
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (j) putchar(' ');
      printf("%d", A[i][j]);
    }
    puts("");
  }
  scanf("%*s");
}
