#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int rd() {
  int x = 0, f = 1;
  char c = getchar();
  while (not isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + c - 48;
    c = getchar();
  }
  return x * f;
}
int n = rd();
int a[1005][1005];
int main() {
  n--;
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= n - 1; j++) a[i][j] = (i + j) % n + 1;
  for (int i = 0; i <= n - 1; i++) a[i][n] = a[n][i] = a[i][i], a[i][i] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) printf("%d%c", a[i][j], " \n"[j == n]);
}
