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