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