#include <bits/stdc++.h>
using namespace std;
const int N = 2009;
int jux[N][N];
int tian[N][N];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int k = i;
    for (int j = 1; j <= n - 1; j++) {
      jux[j][i] = k;
      k++;
      if (k == n) k = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    jux[i][n] = jux[n][i] = jux[i][i];
    jux[i][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) cout << jux[i][j] << " ";
    cout << endl;
  }
  return 0;
}
