#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> mapa;
set<int> S;
vector<int> E[200000], I[200000];
int n;
int X[200000], Y[200000];
int grau[200000];
vector<int> ans;
int ja[200000];
void update(int i) {
  if (ja[i]) return;
  int mn = 2;
  for (int j = 0; j < E[i].size(); j++) {
    int viz = E[i][j];
    if (ja[viz]) continue;
    if (mn = min(mn, grau[viz]))
      ;
  }
  if (mn == 0) exit(-1);
  if (mn != 1)
    S.insert(i);
  else if (S.find(i) != S.end())
    S.erase(S.find(i));
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    pair<int, int> p = pair<int, int>(x, y);
    X[i] = x, Y[i] = y;
    mapa[p] = i;
  }
  for (int i = 0; i < n; i++) {
    for (int d = -1; d < 2; d++) {
      pair<int, int> p = pair<int, int>(X[i] + d, Y[i] + 1);
      if (mapa.find(p) != mapa.end()) {
        int id = mapa[p];
        E[i].push_back(id);
        I[id].push_back(i);
        grau[id]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int mn = 2;
    for (int j = 0; j < E[i].size(); j++) {
      int viz = E[i][j];
      if (mn = min(mn, grau[viz]))
        ;
    }
    if (mn != 1) S.insert(i);
  }
  int cur = 0;
  while (S.size() > 0) {
    cur ^= 1;
    int v;
    set<int>::iterator it;
    if (cur) {
      it = S.end();
      it--;
      v = *it;
      S.erase(it);
    } else {
      it = S.begin();
      v = *it;
      S.erase(it);
    }
    ans.push_back(v);
    ja[v] = 1;
    for (int i = 0; i < I[v].size(); i++) {
      update(I[v][i]);
    }
    for (int i = 0; i < E[v].size(); i++) {
      int viz = E[v][i];
      if (ja[viz]) continue;
      grau[viz]--;
      if (grau[viz] == 1) {
        for (int j = 0; j < I[viz].size(); j++) {
          int viz2 = I[viz][j];
          if (viz2 == v) continue;
          update(viz2);
        }
      }
    }
  }
  long long ans2 = 0;
  long long mul = 1;
  for (int i = ans.size() - 1; i >= 0; i--) {
    ans2 += (long long)ans[i] * mul;
    ans2 %= 1000000009;
    mul *= n;
    mul %= 1000000009;
  }
  cout << ans2 << endl;
  return 0;
}
