#include <bits/stdc++.h>
using namespace std;
int x[100000], y[100000];
vector<int> under[100000], over[100000];
int cnt[100000], cntu[100000];
bool used[100000];
bool pode(int i) {
  bool ok = !used[i];
  for (int j = 0; j < over[i].size(); j++) {
    int next = over[i][j];
    if (!used[next] && cntu[next] < 2) ok = false;
  }
  return ok;
}
int main(void) {
  int n, i;
  scanf("%d", &n);
  map<pair<int, int>, int> m;
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    m[make_pair(x[i], y[i])] = i;
  }
  for (i = 0; i < n; i++) {
    for (int d = -1; d <= 1; d++) {
      pair<int, int> next = make_pair(x[i] + d, y[i] - 1);
      if (m.count(next)) {
        int id = m[next];
        under[i].push_back(id);
        cntu[i]++;
        over[id].push_back(i);
        cnt[id]++;
      }
    }
  }
  set<int> s;
  for (i = 0; i < n; i++) {
    if (pode(i)) {
      s.insert(i);
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    set<int>::iterator it;
    if (!(i & 1)) {
      it = s.end();
      it--;
    } else {
      it = s.begin();
    }
    int curr = *it;
    s.erase(it);
    if (!pode(curr)) {
      i--;
      continue;
    }
    used[curr] = true;
    ans = (ans * n) % 1000000009;
    ans = (ans + curr) % 1000000009;
    for (int j = 0; j < over[curr].size(); j++) {
      int next = over[curr][j];
      cntu[next]--;
      if (pode(next)) {
        s.insert(next);
      }
    }
    for (int j = 0; j < under[curr].size(); j++) {
      int next = under[curr][j];
      cnt[next]--;
      if (pode(next)) {
        s.insert(next);
      }
    }
  }
  cout << ans << endl;
}
