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