#include <bits/stdc++.h>
using namespace std;
const int MX = (1 << 20), dx[3] = {1, 0, -1}, MOD = 1000000009;
map<pair<int, int>, int> idx;
int n;
set<int> nxtv[MX], prevv[MX], S;
void construct_edges() {
  for (auto it : idx) {
    int x = it.first.first, y = it.first.second, Idx = it.second, nx, ny, nIdx;
    for (int j = 0; j < 3; j++) {
      nx = x + dx[j], ny = y - 1;
      if (idx.count(make_pair(nx, ny)) == 0) continue;
      nIdx = idx[make_pair(nx, ny)];
      nxtv[Idx].insert(nIdx);
      prevv[nIdx].insert(Idx);
    }
  }
}
bool is_stable(int x) { return nxtv[x].size() > 1; }
bool check(int x) {
  bool ret = 1;
  for (auto it : prevv[x]) ret &= is_stable(it);
  return ret;
}
void relax(int x) {
  int prev, nxt;
  for (auto it : prevv[x]) {
    prev = it;
    nxtv[prev].erase(x);
    if (nxtv[prev].size() == 1) S.erase(*nxtv[prev].begin());
  }
  for (auto it : nxtv[x]) {
    nxt = it;
    prevv[nxt].erase(x);
    if (check(nxt)) S.insert(nxt);
  }
  S.erase(x);
}
int main() {
  cin >> n;
  for (int j = 0; j < n; j++) {
    int x, y;
    cin >> x >> y;
    idx[make_pair(x, y)] = j;
  }
  construct_edges();
  for (int j = 0; j < n; j++)
    if (check(j)) S.insert(j);
  int turn = 0;
  vector<long long> pow;
  pow.resize(n);
  pow[0] = 1;
  for (int j = 1; j < n; j++) pow[j] = (n * pow[j - 1]) % MOD;
  long long ans = 0;
  int iter = -1;
  while (!S.empty()) {
    int removed;
    iter++;
    if (!turn)
      removed = *--S.end();
    else
      removed = *S.begin();
    relax(removed);
    ans += (removed * pow[n - iter - 1]) % MOD;
    ans %= MOD;
    turn ^= 1;
  }
  cout << ans << endl;
}
