#include <bits/stdc++.h>
using namespace std;
long n, x[1 << 20], y[1 << 20];
set<pair<long, long> > have;
map<pair<long, long>, long> mapp;
pair<long, long> tp;
long mark[1 << 20];
long stand[1 << 20];
long bad[1 << 20];
set<long> nice;
set<long>::iterator it;
long long ans;
long crits[1 << 20];
void reeval(pair<long, long> p) {
  if (have.find(p) == have.end()) return;
  long id = mapp[p];
  stand[id] = 0;
  pair<long, long> tp;
  tp = make_pair(p.first - 1, p.second - 1);
  if (have.find(tp) != have.end()) ++stand[id];
  tp.first++;
  if (have.find(tp) != have.end()) ++stand[id];
  tp.first++;
  if (have.find(tp) != have.end()) ++stand[id];
  if (stand[id] > 1) return;
  tp.first -= 2;
  while (have.find(tp) == have.end()) ++tp.first;
  long danger = mapp[tp];
  if (nice.find(danger) != nice.end()) nice.erase(danger);
}
void recheck(pair<long, long> p) {
  if (have.find(p) == have.end()) return;
  if (nice.find(mapp[p]) != nice.end()) return;
  nice.insert(mapp[p]);
  pair<long, long> tp;
  tp = make_pair(p.first - 1, p.second + 1);
  reeval(tp);
  tp.first++;
  reeval(tp);
  tp.first++;
  reeval(tp);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    have.insert(make_pair(x[i], y[i]));
    mapp[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < n; i++) {
    if (y[i] == 0) {
      stand[i] = 0;
      continue;
    }
    tp = make_pair(x[i] - 1, y[i] - 1);
    if (have.find(tp) != have.end()) ++stand[i];
    tp.first++;
    if (have.find(tp) != have.end()) ++stand[i];
    tp.first++;
    if (have.find(tp) != have.end()) ++stand[i];
  }
  for (int i = 0; i < n; i++) {
    tp = make_pair(x[i] - 1, y[i] + 1);
    if (have.find(tp) != have.end()) {
      int id = mapp[tp];
      if (stand[id] == 1) bad[i] = 1;
    }
    tp.first++;
    if (have.find(tp) != have.end()) {
      int id = mapp[tp];
      if (stand[id] == 1) bad[i] = 1;
    }
    tp.first++;
    if (have.find(tp) != have.end()) {
      int id = mapp[tp];
      if (stand[id] == 1) bad[i] = 1;
    }
  }
  for (int i = 0; i < n; i++)
    if (bad[i] == 0) nice.insert(i);
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      it = nice.end();
      --it;
    } else {
      it = nice.begin();
    }
    int id = (*it);
    ans = ans * n + id;
    ans %= 1000000009;
    have.erase(make_pair(x[id], y[id]));
    nice.erase(it);
    tp = make_pair(x[id] - 1, y[id] + 1);
    reeval(tp);
    tp.first++;
    reeval(tp);
    tp.first++;
    reeval(tp);
    tp = make_pair(x[id] - 1, y[id] - 1);
    recheck(tp);
    tp.first++;
    recheck(tp);
    tp.first++;
    recheck(tp);
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
