#include <bits/stdc++.h>
using namespace std;
struct cube {
  int x, y;
  bool taken = false;
  bool takeable;
};
int m;
cube cs[100111];
map<pair<int, int>, int> fig;
long long res;
priority_queue<int> player1;
priority_queue<int, vector<int>, greater<int> > player2;
void check(int x, int y) {
  if (fig.count(make_pair(x, y))) {
    bool take = true;
    take = take && (!(fig.count(make_pair(x - 1, y + 1)) &&
                      (!fig.count(make_pair(x - 2, y))) &&
                      (!fig.count(make_pair(x - 1, y)))));
    take = take && (!(fig.count(make_pair(x, y + 1)) &&
                      (!fig.count(make_pair(x - 1, y))) &&
                      (!fig.count(make_pair(x + 1, y)))));
    take = take && (!(fig.count(make_pair(x + 1, y + 1)) &&
                      (!fig.count(make_pair(x + 1, y))) &&
                      (!fig.count(make_pair(x + 2, y)))));
    cs[fig[make_pair(x, y)]].takeable =
        take && (!cs[fig[make_pair(x, y)]].taken);
    if (cs[fig[make_pair(x, y)]].takeable &&
        (!cs[fig[make_pair(x, y)]].taken)) {
      player1.push(fig[make_pair(x, y)]);
      player2.push(fig[make_pair(x, y)]);
    }
  }
}
int main() {
  cin >> m;
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    cin >> cs[i].x >> cs[i].y;
    fig.emplace(make_pair(cs[i].x, cs[i].y), i);
  }
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    check(cs[i].x, cs[i].y);
  }
  for (int(i) = 0; (i) < (int)(m); ++(i)) {
    int add;
    if (i % 2) {
      while ((!player2.empty()) && (!cs[player2.top()].takeable)) {
        player2.pop();
      }
      add = player2.top();
    } else {
      while ((!player1.empty()) && (!cs[player1.top()].takeable)) {
        player1.pop();
      }
      add = player1.top();
    }
    res = (res * m + add) % 1000000009;
    cs[add].taken = true;
    cs[add].takeable = false;
    fig.erase(make_pair(cs[add].x, cs[add].y));
    check(cs[add].x - 1, cs[add].y);
    check(cs[add].x - 2, cs[add].y);
    check(cs[add].x + 1, cs[add].y);
    check(cs[add].x + 2, cs[add].y);
    check(cs[add].x - 1, cs[add].y - 1);
    check(cs[add].x, cs[add].y - 1);
    check(cs[add].x + 1, cs[add].y - 1);
  }
  cout << res << endl;
  return 0;
}
