#include <bits/stdc++.h>
using namespace std;
char fi;
const int INF = 2000000000;
const long long int p = 1000000009;
int main() {
  ios_base::sync_with_stdio(false);
  int m;
  cin >> m;
  vector<set<int> > g(m), gt(m);
  map<pair<int, int>, int> sida;
  int x, y;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    sida.insert(pair<pair<int, int>, int>(pair<int, int>(x, y), i));
  }
  for (map<pair<int, int>, int>::iterator it = sida.begin(); it != sida.end();
       ++it) {
    int xp = it->first.first, yp = it->first.second, u = it->second;
    for (int d = -1; d <= 1; ++d) {
      map<pair<int, int>, int>::iterator cosa =
          sida.find(pair<int, int>(xp + d, yp - 1));
      if (cosa != sida.end()) {
        g[cosa->second].insert(u);
      }
      cosa = sida.find(pair<int, int>(xp + d, yp + 1));
      if (cosa != sida.end()) {
        gt[cosa->second].insert(u);
      }
    }
  }
  set<int> puc, nop;
  for (int i = 0; i < m; ++i) {
    bool nec = false;
    for (set<int>::iterator j = g[i].begin(); j != g[i].end(); ++j)
      if (gt[*j].size() == 1) nec = true;
    if (nec)
      nop.insert(i);
    else
      puc.insert(i);
  }
  vector<int> ans(m, -1);
  for (int i = 0; i < int(ans.size()); ++i) {
    int r;
    if (i % 2 == 0)
      r = *puc.rbegin();
    else
      r = *puc.begin();
    ans[i] = r;
    puc.erase(r);
    for (set<int>::iterator j = g[r].begin(); j != g[r].end(); ++j) {
      gt[*j].erase(r);
    }
    for (set<int>::iterator j = gt[r].begin(); j != gt[r].end(); ++j) {
      g[*j].erase(r);
    }
    for (set<int>::iterator j = gt[r].begin(); j != gt[r].end(); ++j) {
      bool nec = false;
      for (set<int>::iterator k = g[*j].begin(); k != g[*j].end(); ++k)
        if (gt[*k].size() == 1) nec = true;
      if (not nec and nop.find(*j) != nop.end()) {
        nop.erase(*j);
        puc.insert(*j);
      }
    }
    for (set<int>::iterator j = g[r].begin(); j != g[r].end(); ++j) {
      for (set<int>::iterator k = gt[*j].begin(); k != gt[*j].end(); ++k)
        if (*k != r) {
          bool nec = false;
          for (set<int>::iterator l = g[*k].begin(); l != g[*k].end(); ++l)
            if (gt[*l].size() == 1) nec = true;
          if (nec and puc.find(*k) != puc.end()) {
            nop.insert(*k);
            puc.erase(*k);
          }
        }
    }
  }
  long long int hans = 0;
  for (int i = 0; i < int(ans.size()); ++i) {
    hans *= m;
    hans += ans[i];
    hans = hans % p;
  }
  cout << hans << '\n';
}
