#include <bits/stdc++.h>
using namespace std;
int N, M, T;
int tb[1005][1005];
int main() {
  int i, j, k, a, b, c;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    for (a = i, b = 0; a >= 0; a--, b++) tb[a][b] = i;
  }
  for (i = 2; i < N - 1; i++) {
    for (a = N - 2, b = i; b < N - 1; a--, b++) tb[a][b] = i - 1;
  }
  for (i = 1; i < N / 2; i++) {
    tb[i][N - 1] = 2 * i;
    tb[N - 1][i] = 2 * i;
  }
  for (i = 0; i < N / 2; i++) {
    tb[N / 2 + i][N - 1] = 2 * i + 1;
    tb[N - 1][N / 2 + i] = 2 * i + 1;
  }
  for (i = 0; i < N; i++) tb[i][i] = 0;
  for (i = 0; i < N; i++) {
    printf("%d", tb[i][0]);
    for (j = 1; j < N; j++) printf(" %d", tb[i][j]);
    printf("\n");
  }
  scanf(" ");
}
