#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
int n;
vector<int> vec;
int main() {
  ios::sync_with_stdio(false), cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++)
    if (i & 1) vec.push_back(i);
  for (int i = 1; i < n; i++)
    if ((i & 1) == 0) vec.push_back(i);
  for (int i = 0; i < n; i++, cout << '\n')
    for (int j = 0; j < n; j++)
      if (i == j)
        cout << 0 << ' ';
      else if (i == n - 1)
        cout << vec[j] << ' ';
      else if (j == n - 1)
        cout << vec[i] << ' ';
      else
        cout << (i + j + 1 < n ? i + j + 1 : i + j + 1 - n + 1) << ' ';
  return 0;
}
