#include <bits/stdc++.h>
using namespace std;
int a[1010][1010];
int b[1010];
int main() {
  int n;
  scanf("%d", &n);
  n = n - 1;
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j >= 0; j--) {
      a[i][(j - i + n) % n] = j + 1;
    }
  }
  for (int i = 0; i < n; i++) {
    b[i] = a[i][i];
    a[i][i] = 0;
  }
  for (int i = 0; i < n; i++) a[i][n] = b[i];
  for (int i = 0; i < n; i++) a[n][i] = b[i];
  a[n][n] = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) cout << a[i][j] << " ";
    cout << endl;
  }
}
