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