#include <bits/stdc++.h>
const int N = 1e3;
int n, a[N + 5][N + 5];
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) {
    int t = a[i][i];
    a[i][i] = a[i][n - 1];
    a[i][n - 1] = t;
  }
  for (int i = 0; i < n - 1; ++i) a[n - 1][i] = a[i][n - 1];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) printf("%d ", a[i][j]);
    puts("");
  }
  return 0;
}
