#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;
template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}
struct XorShift {
  using result_type = ll;
  result_type w = 123456789, x = 362436069, y = 521288629, z = 88675123;
  XorShift(result_type seed = time(nullptr)) {
    w = seed;
    x = w << 13;
    y = (w >> 9) ^ (x << 6);
    z = y >> 7;
  }
  result_type rand() {
    result_type t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    return w = (w ^ (w >> 19) ^ (t ^ (t >> 8)));
  }
  result_type randInt(result_type min = 1, result_type max = 0xFFFFFFFF * 2) {
    return rand() % (max - min + 1) + min;
  }
};
int n;
XorShift rnd;
int cnt = 0;
bool solve(const vector<vector<ll>> &ret) {
  cout << cnt << endl;
  cnt++;
  vector<int> pos;
  for (int i = 0; i < n; i++) pos.push_back(i);
  unordered_map<ll, ll> mp;
  do {
    ll sum = 0;
    for (int i = 1; i < n; i++) {
      sum += ret[pos[i - 1]][pos[i]];
    }
    assert(sum <= 1e11);
    mp[sum]++;
    if (mp[sum] > 2) return false;
  } while (next_permutation(pos.begin(), pos.end()));
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  vector<vector<ll>> ret(n, vector<ll>(n, 0));
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ret[i][j] = ret[j][i] = rnd.randInt();
    }
  }
  if (n <= 9) {
    while (!solve(ret)) {
      for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
          ret[i][j] = ret[j][i] = rnd.randInt();
        }
      }
    }
    for (int i = 0; i < n; i++) {
      printv(ret[i]);
    }
    return 0;
  }
  assert(false);
}
