#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
int main() {
  memset(a, 0, sizeof(a));
  int n;
  int i, j;
  cin >> n;
  for (i = 0; i < n - 1; i++)
    for (j = 0; j < n - 1; j++) a[i][j] = 1 + (i + j) % (n - 1);
  for (i = 0; i < n; i++) a[i][n - 1] = a[n - 1][i] = a[i][i], a[i][i] = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cout << a[i][j];
      if (j != n - 1) cout << " ";
    }
    cout << endl;
  }
  return 0;
}
