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