#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
int a[N][N];
int main() {
  int n;
  string s;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (cin >> n) {
    n -= 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) a[i][j] = (i + j) % n + 1;
    for (int i = 0; i < n; i++)
      a[i][n] = a[i][i], a[n][i] = a[i][i], a[i][i] = 0;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) cout << a[i][j] << ' ';
      cout << endl;
    }
  }
  return 0;
}
