#include <bits/stdc++.h>
using namespace std;
int book[1005][1005];
int main() {
  int n;
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - 1; j++) book[i][j] = (i + j) % (n - 1) + 1;
  }
  for (int i = 0; i < n; i++) {
    book[i][n - 1] = book[i][i];
    book[n - 1][i] = book[i][i];
    book[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cout << book[i][j] << " ";
    cout << endl;
  }
}
