#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll linf = 1e18;
const double eps = 1e-12, pi = acos(-1);
template <typename T>
ll min(ll a, const T&& b) {
  return a < b ? a : b;
}
template <typename T>
ll min(const T&& a, ll b) {
  return a < b ? a : b;
}
template <typename T>
ll max(ll a, const T&& b) {
  return a > b ? a : b;
}
template <typename T>
ll max(const T&& a, ll b) {
  return a > b ? a : b;
}
template <typename Head>
void out(Head h) {
  cout << h << endl;
}
template <typename Head, typename... Tail>
void out(Head h, Tail... t) {
  cout << h << " ";
  out(t...);
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto&& x : v) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
ostream& operator<<(ostream& os, const vector<string>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << endl;
    os << v[i];
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
  for (ll i = (0), __last_i = (v.size()); i < __last_i; i++) {
    if (i) os << endl;
    os << v[i];
  }
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
struct yes_no : std::numpunct<char> {
  string_type do_truename() const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  locale loc(locale(), new yes_no);
  cout.imbue(loc);
  cout << fixed << setprecision(10) << boolalpha;
  solve();
}
vector<vector<vector<ll>>> ans{
    {{0, 9000000000}, {9000000000, 0}},
    {{0, 9000000000, 8806623449},
     {9000000000, 0, 8395848399},
     {8806623449, 8395848399, 0}},
    {{0, 7797245639, 6826442229, 9000000000},
     {7797245639, 0, 8084682270, 6622263879},
     {6826442229, 8084682270, 0, 5398865136},
     {9000000000, 6622263879, 5398865136, 0}},
    {{0, 8687683518, 7772297764, 8448747466, 9000000000},
     {8687683518, 0, 8524254759, 7965515337, 8855555047},
     {7772297764, 8524254759, 0, 7199419454, 7286635373},
     {8448747466, 7965515337, 7199419454, 0, 6037875949},
     {9000000000, 8855555047, 7286635373, 6037875949, 0}},
    {{0, 5435248726, 8243428291, 8134904948, 9000000000, 8059319994},
     {5435248726, 0, 6277014323, 8521611907, 5191374053, 8665697446},
     {8243428291, 6277014323, 0, 6681937751, 6655919757, 8499524066},
     {8134904948, 8521611907, 6681937751, 0, 5792258825, 6707398173},
     {9000000000, 5191374053, 6655919757, 5792258825, 0, 8023810688},
     {8059319994, 8665697446, 8499524066, 6707398173, 8023810688, 0}},
    {{0, 8904181102, 5928414918, 9000000000, 8657241419, 8830525562,
      8566185653},
     {8904181102, 0, 6714262024, 7706079523, 8530183960, 8874036514,
      8820993802},
     {5928414918, 6714262024, 0, 5630604791, 8664527712, 7167186194,
      7631393291},
     {9000000000, 7706079523, 5630604791, 0, 8806553278, 4639301010,
      8877085136},
     {8657241419, 8530183960, 8664527712, 8806553278, 0, 8448281858,
      8752072886},
     {8830525562, 8874036514, 7167186194, 4639301010, 8448281858, 0,
      2889384801},
     {8566185653, 8820993802, 7631393291, 8877085136, 8752072886, 2889384801,
      0}},
    {{0, 8958182635, 5565521127, 8635789273, 8038035454, 8756279963, 4479735819,
      7305115937},
     {8958182635, 0, 7052830516, 4300743862, 8771462309, 7902106717, 8139689665,
      8344167565},
     {5565521127, 7052830516, 0, 7857457459, 6471774524, 7730704513, 3374467433,
      9000000000},
     {8635789273, 4300743862, 7857457459, 0, 8467169869, 4090012498, 8978641134,
      7033515947},
     {8038035454, 8771462309, 6471774524, 8467169869, 0, 8594507257, 8660882314,
      8084587729},
     {8756279963, 7902106717, 7730704513, 4090012498, 8594507257, 0, 8126799507,
      3506941496},
     {4479735819, 8139689665, 3374467433, 8978641134, 8660882314, 8126799507, 0,
      8272973178},
     {7305115937, 8344167565, 9000000000, 7033515947, 8084587729, 3506941496,
      8272973178, 0}},
    {{0, 7864006222, 6586514571, 8659788021, 2858366966, 7376606455, 8422434484,
      8536879817, 8702394374},
     {7864006222, 0, 6972580044, 8668100688, 8194261910, 8293556803, 5964862179,
      8549756827, 8882807669},
     {6586514571, 6972580044, 0, 8735728988, 8763577845, 7405622856, 8044734719,
      7144991499, 6642183750},
     {8659788021, 8668100688, 8735728988, 0, 5350596445, 7685392397, 8244942952,
      8444621838, 8050311485},
     {2858366966, 8194261910, 8763577845, 5350596445, 0, 8778772846, 8881423196,
      7793669350, 8935584998},
     {7376606455, 8293556803, 7405622856, 7685392397, 8778772846, 0, 8677999970,
      8984854873, 8755907088},
     {8422434484, 5964862179, 8044734719, 8244942952, 8881423196, 8677999970, 0,
      9000000000, 7429275053},
     {8536879817, 8549756827, 7144991499, 8444621838, 7793669350, 8984854873,
      9000000000, 0, 8923611366},
     {8702394374, 8882807669, 6642183750, 8050311485, 8935584998, 8755907088,
      7429275053, 8923611366, 0}},
};
void solve() {
  ll n;
  cin >> n;
  assert(n - 2 < ans.size());
  cout << ans[n - 2] << endl;
}
