#include <bits/stdc++.h>
using namespace std;
int s[1010][1010];
int N;
void out() {
  for (int i = 1; i <= N + 1; i++) {
    for (int j = 1; j <= N + 1; j++) printf("%d ", s[i][j]);
    putchar('\n');
  }
  return;
}
int main() {
  cin >> N;
  N--;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) s[i][j] = (i + j - 2) % N + 1;
  for (int i = 1; i <= N; i++) {
    s[i][N + 1] = s[N + 1][i] = s[i][i];
    s[i][i] = 0;
  }
  out();
  return 0;
}
