#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
const int INF = 1000000000, mod = 1000000009;
const long long LLINF = 1000000000000000000ll;
struct cube {
  int x, y, c;
  cube() {}
  cube(int x, int y, int c) : x(x), y(y), c(c) {}
  bool operator<(const cube &a) const { return c < a.c; }
};
vector<cube> cubes;
set<cube> can;
map<pair<int, int>, int> exists;
vector<int> down[N];
vector<int> up[N];
void recalc(int x, int y) {
  int i = exists[make_pair(x, y)];
  down[i].clear();
  up[i].clear();
  for (int j = -1; j < 2; ++j) {
    pair<int, int> tmp1 = make_pair(x + j, y - 1);
    pair<int, int> tmp2 = make_pair(x + j, y + 1);
    if (exists.count(tmp1)) down[i].push_back(exists[tmp1]);
    if (exists.count(tmp2)) up[i].push_back(exists[tmp2]);
  }
}
void recalc(int i) {
  bool canTake = 1;
  for (size_t j = 0; j < up[i].size(); ++j) {
    int cur = up[i][j];
    if (down[cur].size() == 1) canTake = 0;
  }
  if (canTake) can.insert(cubes[i]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    cubes.push_back(cube(x, y, i));
    exists[make_pair(x, y)] = i;
  }
  for (int i = 0; i < n; ++i) {
    recalc(cubes[i].x, cubes[i].y);
  }
  for (int i = 0; i < n; ++i) {
    recalc(i);
  }
  vector<int> result;
  for (int i = 0; i < n; ++i) {
    auto iter = (i % 2 == 1 ? can.begin() : --can.end());
    cube tmp = *iter;
    can.erase(iter);
    exists.erase(make_pair(tmp.x, tmp.y));
    result.push_back(tmp.c);
    for (int dx = -2; dx <= 2; ++dx) {
      for (int dy = -2; dy <= 2; ++dy) {
        pair<int, int> pt = make_pair(tmp.x + dx, tmp.y + dy);
        if (!exists.count(pt)) continue;
        recalc(pt.first, pt.second);
        can.erase(cube(pt.first, pt.second, exists[pt]));
      }
    }
    for (int dx = -2; dx <= 2; ++dx) {
      for (int dy = -2; dy <= 2; ++dy) {
        pair<int, int> pt = make_pair(tmp.x + dx, tmp.y + dy);
        if (!exists.count(pt)) continue;
        recalc(exists[pt]);
      }
    }
  }
  reverse(result.begin(), result.end());
  long long answer = 0ll, curPow = 1ll;
  for (size_t i = 0; i < result.size(); ++i) {
    answer = (answer + curPow * result[i]) % mod;
    curPow = (curPow * n) % mod;
  }
  printf("%I64d\n", answer);
  return 0;
}
