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