#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count, lastnumber;
  vector<int> last;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    count = i;
    lastnumber = 0;
    for (int j = 0; j < n; j++) {
      if (j < n - 1) {
        if (i == j) {
          cout << 0 << " ";
          lastnumber = count;
        } else {
          cout << count << " ";
        }
      } else if (i > 0) {
        cout << lastnumber << "\n";
        last.push_back(lastnumber);
      } else {
        last.push_back(count);
        cout << count << "\n";
      }
      count++;
      if (count >= n) {
        count = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i < n - 1) {
      cout << last[i] << " ";
    } else {
      cout << 0 << "\n";
    }
  }
  return 0;
}
