#include <bits/stdc++.h>
using namespace std;
int a[1010][1010];
int main() {
  int i, j, k, n;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) a[0][i] = i + 1;
    for (i = 1; i < n; i++) {
      for (j = 0; j < n; j++) {
        k = i + j;
        if (k >= n - 1) k = k - n + 1;
        a[i][j] = a[0][k];
      }
    }
    for (i = 0; i < n; i++) {
      a[n - 1][i] = a[i][n - 1] = a[i][i];
      a[i][i] = 0;
    }
    for (i = 0; i < n; i++) {
      printf("%d", a[i][0]);
      for (j = 1; j < n; j++) printf(" %d", a[i][j]);
      printf("\n");
    }
  }
  return 0;
}
