#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int> > mat(n);
  for (int i = 0; i < n; ++i) {
    mat[i].resize(n);
  }
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < n - 1; ++j) {
      mat[i][j] = 1 + (i + j) % (n - 1);
    }
  }
  for (int i = 0; i < n; ++i) {
    mat[i][n - 1] = mat[i][i];
    mat[n - 1][i] = mat[i][i];
    mat[i][i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cout << mat[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
