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