#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n - 1];
  int b[n - 1];
  for (int i = 0; i < n - 1; i++) a[i] = i;
  for (int i = 0; i < n - 1; i++) {
    for (int k = 0; k < n - 1; k++) {
      int j = (i + k) % (n - 1);
      int e = (a[j] == 0 ? n - 1 : a[j]);
      if (k == i) {
        b[i] = e;
        cout << 0 << " ";
      } else
        cout << e << " ";
    }
    cout << b[i] << endl;
  }
  for (int i = 0; i < n - 1; i++) {
    cout << b[i] << " ";
  }
  cout << "0" << endl;
  return 0;
}
