#include <bits/stdc++.h>
using namespace std;
int matrix[1010][1010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int k = 0;
  for (int i = 1; i < n; ++i) {
    k = i;
    if (i == n - 1) {
      matrix[i][0] = matrix[0][i] = i;
      k = 2;
      for (int j = 1; j < i; ++j) {
        matrix[i][j] = matrix[j][i] = k;
        k = (k + 2) % n;
        if (!k) k = 1;
      }
    } else {
      for (int j = 0; j < i; ++j) {
        matrix[i][j] = matrix[j][i] = k;
        k = (k + 1) % n;
        if (!k) k = 1;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) cout << matrix[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
