#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int** A;
  cin >> n;
  int current;
  A = (int**)malloc(sizeof(int*) * n);
  for (int i = 0; i < n; i++) A[i] = (int*)malloc(sizeof(int) * n);
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - 1; j++) {
      if (i == j)
        A[i][j] = 0;
      else
        A[i][j] = 1 + (i + j) % (n - 1);
    }
    A[i][n - 1] = 1 + (2 * i) % (n - 1);
    A[n - 1][i] = 1 + (2 * i) % (n - 1);
  }
  A[n - 1][n - 1] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << A[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
