#include <bits/stdc++.h>
using namespace std;
int p[1007][1007], n;
int main() {
  while (cin >> n) {
    n--;
    memset(p, 0, sizeof(p));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) p[i][j] = (i + j) % n + 1;
    for (int i = 0; i < n; i++) p[i][n] = p[n][i] = p[i][i], p[i][i] = 0;
    for (int i = 0; i <= n; i++) {
      printf("%d", p[i][0]);
      for (int j = 1; j <= n; j++) printf(" %d", p[i][j]);
      printf("\n");
    }
  }
}
