#include <bits/stdc++.h>
using namespace std;
int ans[1010][1010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      ans[i][j] = (j + i - 1) % (n - 1);
      if (ans[i][j] == 0) ans[i][j] = n - 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    ans[n][i] = ans[i][n] = ans[i][i];
    ans[i][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) printf("%d ", ans[i][j]);
    puts("");
  }
}
