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