#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
const long long mod = 1e9 + 9;
map<pair<int, int>, int> S;
map<pair<int, int>, int>::iterator p;
set<int> f;
set<int>::iterator q;
vector<int> G[MAX], Gr[MAX];
vector<int>::iterator r;
int n, x, y, id;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  pair<int, int> aux;
  for (int i = 0; i < n; i++) {
    cin >> aux.first >> aux.second;
    S[aux] = i;
  }
  for (p = S.begin(); p != S.end(); ++p) {
    x = p->first.first;
    y = p->first.second;
    id = p->second;
    if (S.find(make_pair(x, y - 1)) != S.end()) {
      G[id].push_back(S[make_pair(x, y - 1)]);
      Gr[S[make_pair(x, y - 1)]].push_back(id);
    }
    if (S.find(make_pair(x - 1, y - 1)) != S.end()) {
      G[id].push_back(S[make_pair(x - 1, y - 1)]);
      Gr[S[make_pair(x - 1, y - 1)]].push_back(id);
    }
    if (S.find(make_pair(x + 1, y - 1)) != S.end()) {
      G[id].push_back(S[make_pair(x + 1, y - 1)]);
      Gr[S[make_pair(x + 1, y - 1)]].push_back(id);
    }
  }
  bool yes;
  for (int i = 0; i < n; i++) {
    yes = true;
    for (int j = 0; j < Gr[i].size(); j++) {
      if (G[Gr[i][j]].size() < 2) yes = false;
    }
    if (yes == true) f.insert(i);
  }
  long long sol = 0;
  int IN;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      IN = *f.rbegin();
      f.erase(IN);
      sol *= (long long)n;
      sol += (long long)IN;
      sol %= mod;
    } else {
      IN = *f.begin();
      f.erase(IN);
      sol *= (long long)n;
      sol += (long long)IN;
      sol %= mod;
    }
    for (int j = 0; j < Gr[IN].size(); j++) {
      for (r = G[Gr[IN][j]].begin(); r != G[Gr[IN][j]].end(); ++r) {
        if (*r == IN) {
          G[Gr[IN][j]].erase(r);
          break;
        }
      }
      if (G[Gr[IN][j]].size() < 2) {
        if (f.find(G[Gr[IN][j]][0]) != f.end()) {
          f.erase(*f.find(G[Gr[IN][j]][0]));
        }
      }
    }
    for (int j = 0; j < G[IN].size(); j++) {
      for (r = Gr[G[IN][j]].begin(); r != Gr[G[IN][j]].end(); ++r) {
        if (*r == IN) {
          Gr[G[IN][j]].erase(r);
          break;
        }
      }
      yes = true;
      for (int k = 0; k < Gr[G[IN][j]].size(); k++)
        if (G[Gr[G[IN][j]][k]].size() < 2) yes = false;
      if (yes == true) f.insert(G[IN][j]);
    }
    G[IN].clear();
    Gr[IN].clear();
  }
  cout << sol << endl;
}
