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