#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 9;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const int N = 1e5 + 20;
long long n, ans, d;
map<pair<long long, long long>, long long> id;
set<pair<long long, pair<long long, long long> > > s;
set<pair<long long, long long> > a;
int cnt(pair<long long, long long> p) {
  int res = 3, x = p.first, y = p.second;
  if (a.find(make_pair(x - 1, y - 1)) == a.end()) res--;
  if (a.find(make_pair(x, y - 1)) == a.end()) res--;
  if (a.find(make_pair(x + 1, y - 1)) == a.end()) res--;
  return res;
}
bool check(pair<long long, long long> p) {
  int x = p.first, y = p.second;
  if ((a.find(make_pair(x + 1, y + 1)) != a.end() &&
       cnt(make_pair(x + 1, y + 1)) == 1) ||
      (a.find(make_pair(x, y + 1)) != a.end() &&
       cnt(make_pair(x, y + 1)) == 1) ||
      (a.find(make_pair(x - 1, y + 1)) != a.end() &&
       cnt(make_pair(x - 1, y + 1)) == 1))
    return 0;
  return 1;
}
void update(pair<long long, long long> p) {
  int x = p.first, y = p.second;
  pair<long long, long long> t;
  a.erase(p);
  s.erase(make_pair(id[p], p));
  t = make_pair(x - 1, y);
  if (!check(t)) s.erase(make_pair(id[t], t));
  t = make_pair(x + 1, y);
  if (!check(t)) s.erase(make_pair(id[t], t));
  t = make_pair(x - 2, y);
  if (!check(t)) s.erase(make_pair(id[t], t));
  t = make_pair(x + 2, y);
  if (!check(t)) s.erase(make_pair(id[t], t));
  t = make_pair(x - 1, y - 1);
  if (a.find(t) != a.end() && check(t)) s.insert(make_pair(id[t], t));
  t = make_pair(x, y - 1);
  if (a.find(t) != a.end() && check(t)) s.insert(make_pair(id[t], t));
  t = make_pair(x + 1, y - 1);
  if (a.find(t) != a.end() && check(t)) s.insert(make_pair(id[t], t));
}
long long powmod(long long x, long long y, long long MODD = MOD) {
  if (y == 0) return 1LL;
  long long tmp = powmod(x, y / 2, MODD);
  tmp = ((tmp) * (tmp)) % MODD;
  return (tmp * (y % 2 ? (x % MODD) : 1LL)) % MODD;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  d = n - 1;
  for (int i = 0, x, y; i < n; i++) {
    cin >> x >> y;
    a.insert(make_pair(x, y));
    id[make_pair(x, y)] = i;
  }
  for (auto x : a)
    if (check(x)) s.insert(make_pair(id[x], x));
  while (a.size()) {
    auto f = *s.rbegin();
    ans = (ans + f.first * powmod(n, d--)) % MOD;
    update(f.second);
    auto g = *s.begin();
    ans = (ans + g.first * powmod(n, d--)) % MOD;
    update(g.second);
  }
  cout << ans << endl;
}
