#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000 + 10;
int a[maxN][maxN];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < n; ++j) {
      a[i][j] = 1 + (i + j - 2) % (n - 1);
    }
    a[i][n] = a[i][i];
    a[n][i] = a[i][i];
    a[i][i] = 0;
  }
  a[n][n] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
