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