#include <bits/stdc++.h>
using namespace std;
const int N = 200020;
long long int n;
int main() {
  cin >> n;
  for (long long int i = 1; i <= n - 1; i++) {
    for (long long int j = 1; j <= n - 1; j++) {
      if (i == j)
        cout << "0 ";
      else
        cout << 1 + (i + j - 2) % (n - 1) << " ";
    }
    cout << (2 * i - 2) % (n - 1) + 1 << endl;
  }
  for (long long int i = 1; i <= n - 1; i++) {
    cout << (2 * i - 2) % (n - 1) + 1 << " ";
  }
  cout << "0" << endl;
  return 0;
}
