#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int maxn = 1010;
int a[maxn][maxn];
int n;
int main() {
  cin >> n;
  n--;
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (n - 1); ++j) a[i][j] = 1 + (j + i) % n;
  for (int i = (0); i <= (n); ++i) a[i][n] = a[n][i] = a[i][i];
  for (int i = (0); i <= (n); ++i) a[i][i] = 0;
  for (int i = (0); i <= (n); ++i) {
    for (int j = (0); j <= (n); ++j) printf("%d ", a[i][j]);
    puts("");
  }
  return 0;
}
