#include <bits/stdc++.h>
using namespace std;
bool gt(long double a, long double b) { return a > b + 1e-12; }
int main() {
  int n;
  cin >> n;
  for (register int i = (0); i < (int)(n); ++i) {
    for (register int j = (0); j < (int)(n); ++j) {
      if (i == j)
        cout << 0;
      else if (i < n - 1 && j < n - 1)
        cout << (i + j) % (n - 1) + 1;
      else
        cout << (min(i, j) * 2) % (n - 1) + 1;
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}
