#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> id;
set<int> u[100010], v[100010], ok;
int x[100010] = {0}, y[100010] = {0}, z;
bool no[100010] = {0};
int m;
const long long int mod = 1e9 + 9;
long long int ans = 0;
set<int>::iterator iterCur;
set<int>::iterator iterEnd;
set<int>::iterator iterCurt;
set<int>::iterator iterEndt;
map<pair<int, int>, int>::iterator it;
int main() {
  id.clear();
  ok.clear();
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    id[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < m; i++) {
    int tmp = y[i] - 1;
    for (int j = x[i] - 1; j <= x[i] + 1; j++) {
      it = id.find({j, tmp});
      if (it != id.end()) {
        u[i].insert(it->second);
        v[it->second].insert(i);
      }
    }
  }
  for (int i = 0; i < m; i++)
    if (u[i].size() == 1) no[*u[i].begin()] = true;
  for (int i = 0; i < m; i++)
    if (no[i] == false) ok.insert(i);
  for (int i = 0; i < m; i++) {
    int id1;
    if (i % 2 == 1)
      id1 = *ok.begin();
    else
      id1 = *ok.rbegin();
    ok.erase(id1);
    ans = (ans * m % mod + id1) % mod;
    iterCur = v[id1].begin();
    iterEnd = v[id1].end();
    for (; iterCur != iterEnd; ++iterCur) {
      u[*iterCur].erase(id1);
      if (u[*iterCur].size() == 1 && !no[z = *u[*iterCur].begin()]) {
        no[z] = true;
        ok.erase(z);
      }
    }
    iterCur = u[id1].begin();
    iterEnd = u[id1].end();
    for (; iterCur != iterEnd; ++iterCur) {
      v[*iterCur].erase(id1);
      ok.insert(*iterCur);
      no[*iterCur] = false;
      iterCurt = v[*iterCur].begin();
      iterEndt = v[*iterCur].end();
      for (; iterCurt != iterEndt; ++iterCurt) {
        if (u[*iterCurt].size() == 1) {
          no[*iterCur] = true;
          ok.erase(*iterCur);
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
