#include <bits/stdc++.h>
const int N = 1005;
int a[N][N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    a[1][i] = n - i;
  }
  for (int i = 2; i < n; i++) {
    for (int j = 1; j < n; j++) {
      a[i][j] = a[i - 1][j + 1];
    }
    a[i][n - 1] = a[i - 1][1];
  }
  for (int i = 1; i <= n; i++) {
    a[n][i] = a[i][n] = a[i][i];
    a[i][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      printf("%d ", a[i][j]);
    }
    puts("");
  }
  return 0;
}
