#include <bits/stdc++.h>
using namespace std;
constexpr long long mod = 1000000007;
const long long INF = mod * mod;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<vector<long long>> ans[11];
void init() {
  ans[7] = {{0, 1, 13, 180, 1903, 11970, 123567},
            {1, 0, 23, 259, 2324, 25037, 215370},
            {13, 23, 0, 370, 3270, 32755, 339250},
            {180, 259, 370, 0, 4801, 47005, 482983},
            {1903, 2324, 3270, 4801, 0, 50156, 501509},
            {11970, 25037, 32755, 47005, 50156, 0, 667471},
            {123567, 215370, 339250, 482983, 501509, 667471, 0}};
}
long long a[10][10];
bool valid(int n) {
  vector<int> v(n);
  for (int i = 0; i < n; i++) v[i] = i;
  vector<long long> cs;
  do {
    long long sum = 0;
    for (int j = 0; j < n - 1; j++) {
      sum += a[v[j]][v[j + 1]];
    }
    cs.push_back(sum);
  } while (next_permutation((v).begin(), (v).end()));
  sort((cs).begin(), (cs).end());
  for (int i = 0; i < cs.size(); i++) {
    int le = i;
    while (i + 1 < cs.size() && cs[i] == cs[i + 1]) i++;
    if (i != le + 1) return false;
  }
  return true;
}
long long c[10][10];
bool subvalid(int n) {
  vector<int> v(n);
  for (int i = 0; i < n; i++) v[i] = i;
  vector<long long> cs;
  do {
    bool f = true;
    long long sum = 0;
    for (int j = 0; j < n - 1; j++) {
      sum += c[v[j]][v[j + 1]];
      if (c[v[j]][v[j + 1]] < 0) f = false;
    }
    if (f) cs.push_back(sum);
  } while (next_permutation((v).begin(), (v).end()));
  sort((cs).begin(), (cs).end());
  for (int i = 0; i < cs.size(); i++) {
    int le = i;
    while (i + 1 < cs.size() && cs[i] == cs[i + 1]) i++;
    if (i != le + 1) return false;
  }
  return true;
}
long long t10[11];
void solve() {
  init();
  t10[0] = 1;
  for (int i = 0; i < 10; i++) t10[i + 1] = t10[i] * 10;
  int n = 10;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      a[i][j] = a[j][i] = (i + 1) * t10[j - 1];
    }
  }
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < n - 1; j++) a[i][j] = ans[n - 1][i][j];
  while (true) {
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        if (j < n - 1) continue;
        long long s = t10[j - 1];
        random_device rnd;
        mt19937 mt(rnd());
        uniform_int_distribution<> uf(0, s - 1);
        long long ori = s * (i + 1);
        a[i][j] = a[j][i] = ori + uf(mt);
      }
    if (valid(n)) break;
  }
  for (int i = 0; i < n; i++) {
    cout << "{";
    for (int j = 0; j < n; j++) {
      if (j > 0) cout << ",";
      cout << a[i][j];
    }
    cout << "},";
    cout << "\n";
  }
}
void solve2() {
  int n = 10;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j)
        c[i][j] = 0;
      else
        c[i][j] = -1;
    }
  t10[0] = 1;
  for (int i = 0; i < 10; i++) t10[i + 1] = t10[i] * 10;
  random_device rnd;
  default_random_engine mt(rnd());
  uniform_real_distribution<> uf(0.0, 1.0);
  long long sup = 10000000000000000;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      long long s = t10[i - 1];
      c[i][j] = c[j][i] = sup * uf(mt);
      while (!subvalid(i + 1)) {
        c[i][j] = c[j][i] = sup * uf(mt);
      }
      cout << "start\n";
      for (int x = 0; x < n; x++) {
        for (int y = 0; y < n; y++) {
          cout << c[x][y] << " ";
        }
        cout << "\n";
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      c[i][j] %= 99999999977;
    }
  }
  if (!subvalid(n)) solve2();
  cout << "fin\n";
}
vector<vector<long long>> tans = {
    {0, 8679254417104694, 801843114523693, 2518366659574325, 3067501635514114,
     8234765506254429, 7201651097314045, 9075112094420646, 8294670012178120,
     5883716482306801},
    {8679254417104694, 0, 4069054154909711, 4208489622453116, 7349787543427716,
     5207174438573487, 7307000362776734, 5026641246851712, 9003468909003195,
     2962004726891630},
    {801843114523693, 4069054154909711, 0, 3887927569369792, 4217162803222042,
     6941112260664091, 1029062450565922, 9160598588088340, 5654544589400040,
     5605099336006955},
    {2518366659574325, 4208489622453116, 3887927569369792, 0, 9982610412800366,
     9769066729858880, 3517489564391076, 9475459332042822, 5321417394102834,
     3616293192831660},
    {3067501635514114, 7349787543427716, 4217162803222042, 9982610412800366, 0,
     1192407682165859, 6981306994797034, 6504225523432847, 3116634251238327,
     8676172122740584},
    {8234765506254429, 5207174438573487, 6941112260664091, 9769066729858880,
     1192407682165859, 0, 8047384683455301, 4448528488459717, 5300289000140481,
     4025778184046098},
    {7201651097314045, 7307000362776734, 1029062450565922, 3517489564391076,
     6981306994797034, 8047384683455301, 0, 6613868747543140, 1511593954860388,
     2107406843181027},
    {9075112094420646, 5026641246851712, 9160598588088340, 9475459332042822,
     6504225523432847, 4448528488459717, 6613868747543140, 0, 6141510099963170,
     2388760530436694},
    {8294670012178120, 9003468909003195, 5654544589400040, 5321417394102834,
     3116634251238327, 5300289000140481, 1511593954860388, 6141510099963170, 0,
     1453417897441860},
    {5883716482306801, 2962004726891630, 5605099336006955, 3616293192831660,
     8676172122740584, 4025778184046098, 2107406843181027, 2388760530436694,
     1453417897441860, 0}};
void truesolve() {
  int n;
  cin >> n;
  long long out[10][10];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      out[i][j] = tans[i][j] % 99999999977;
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j > 0) cout << " ";
      cout << out[i][j];
    }
    cout << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  truesolve();
  char nyaa;
  cin >> nyaa;
  return 0;
}
