#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
const int inf = 2e9 + 2;
const int mod = 1e6 + 3;
const double eps = 1e-7;
int n, m[1010][1010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) m[i][j] = (i + j) % (n - 1) + 1;
  for (int i = 1; i < n; ++i) m[n][i] = m[i][n] = m[i][i], m[i][i] = 0;
  for (int i = 1; i <= n; ++i, puts(""))
    for (int j = 1; j <= n; ++j) cout << m[i][j] << " ";
  return 0;
}
