#include <bits/stdc++.h>
using namespace std;
int m;
int x[100100], y[100100];
int dx[3] = {-1, 0, 1};
int only[100100];
bool used[100100];
map<pair<int, int>, int> M;
struct cube {
  int x, y, id;
  cube(int x, int y, int id) : x(x), y(y), id(id) {}
  bool operator<(const cube& a) const { return y > a.y; }
};
set<int> s;
vector<cube> vec;
void update(int v) {
  int cnt = 0;
  map<pair<int, int>, int>::iterator ch;
  for (int i = 0; i < 3; i++) {
    int nx = x[v] + dx[i];
    int ny = y[v] - 1;
    map<pair<int, int>, int>::iterator it = M.find(pair<int, int>(nx, ny));
    if (it != M.end() && !used[it->second]) {
      cnt++;
      ch = it;
    }
  }
  if (cnt == 1) {
    if (only[ch->second] == 0) s.erase(ch->second);
    only[ch->second]++;
  }
}
int main() {
  scanf("%d", &m);
  for (int i = 0; i < m; i++) scanf("%d %d", &x[i], &y[i]);
  for (int i = 0; i < m; i++) M[pair<int, int>(x[i], y[i])] = i;
  for (int i = 0; i < m; i++) vec.push_back(cube(x[i], y[i], i));
  sort((vec).begin(), (vec).end());
  for (int i = 0; i < m; i++) {
    cube c = vec[i];
    if (only[c.id] == 0) s.insert(c.id);
    int cnt = 0;
    map<pair<int, int>, int>::iterator ch;
    for (int i = 0; i < 3; i++) {
      int nx = c.x + dx[i];
      int ny = c.y - 1;
      map<pair<int, int>, int>::iterator it = M.find(pair<int, int>(nx, ny));
      if (it != M.end() && !used[it->second]) {
        cnt++;
        ch = it;
      }
    }
    if (cnt == 1) only[ch->second]++;
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    int pull;
    if (i % 2 == 0)
      pull = *s.rbegin();
    else
      pull = *s.begin();
    s.erase(pull);
    ans = (ans * m + pull) % 1000000009;
    used[pull] = true;
    map<pair<int, int>, int>::iterator ch;
    int cnt = 0;
    for (int j = 0; j < 3; j++) {
      int nx = x[pull] + dx[j];
      int ny = y[pull] - 1;
      map<pair<int, int>, int>::iterator it = M.find(pair<int, int>(nx, ny));
      if (it != M.end() && !used[it->second]) {
        cnt++;
        ch = it;
      }
    }
    if (cnt == 1) {
      only[ch->second]--;
      if (only[ch->second] == 0) s.insert(ch->second);
    }
    for (int j = 0; j < 3; j++) {
      int nx = x[pull] + dx[j];
      int ny = y[pull] + 1;
      map<pair<int, int>, int>::iterator it = M.find(pair<int, int>(nx, ny));
      if (it != M.end() && !used[it->second]) update(it->second);
    }
  }
  cout << ans << endl;
  return 0;
}
