#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
int main() {
  int n;
  cin >> n;
  int a[n][n];
  for (int i = 0; i < n; ++i) {
    int r = i, c = 0;
    while (r < n & r >= 0 & c < n & c >= 0) {
      a[r][c] = i;
      r--;
      c++;
    }
    r = n - 1, c = i;
    while (r < n & r >= 0 & c < n & c >= 0) {
      a[r][c] = i;
      r--;
      c++;
    }
  }
  for (int i = 0; i < n; ++i) {
    a[i][n - 1] = (2 * i) % (n - 1);
    if (a[i][n - 1] == 0) a[i][n - 1] = n - 1;
    a[n - 1][i] = a[i][n - 1];
  }
  for (int i = 0; i < n; ++i) {
    a[i][i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int k = 0; k < n; ++k) printf("%d ", a[i][k]);
    printf("\n");
  }
  return 0;
}
