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