#include <bits/stdc++.h>
using namespace std;
const int mmod = 1000000009;
struct xyn {
  int x, y, num;
  xyn() {}
  xyn(int _x, int _y, int _num) {
    x = _x;
    y = _y;
    num = _num;
  }
  bool operator<(const xyn& another) const {
    if (x != another.x) return x < another.x;
    if (y != another.y) return y < another.y;
    return false;
  }
};
int main() {
  int m;
  cin >> m;
  vector<int> x(m), y(m);
  set<xyn> S;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    S.insert(xyn(x[i], y[i], i));
  }
  set<int> candidate;
  for (int i = 0; i < m; i++) {
    int ok = 1;
    for (int plus = -1; plus <= 1; plus++) {
      set<xyn>::iterator it = S.find(xyn(x[i] + plus, y[i] + 1, -1));
      if (it == S.end()) continue;
      int xx = (*it).x;
      int yy = (*it).y;
      int cnt = 0;
      for (int p2 = -1; p2 <= 1; p2++)
        if (S.find(xyn(xx + p2, yy - 1, -1)) != S.end()) cnt++;
      if (cnt < 2) {
        ok = 0;
        break;
      }
    }
    if (ok) candidate.insert(i);
  }
  int res = 0;
  for (int i = 0; i < m; i++) {
    set<int>::iterator it;
    if (i % 2)
      it = candidate.begin();
    else {
      it = candidate.end();
      it--;
    }
    int num = *it;
    S.erase(xyn(x[num], y[num], num));
    candidate.erase(it);
    const int x_plus[7] = {-2, -1, 1, 2, -1, 0, 1};
    const int y_plus[7] = {0, 0, 0, 0, -1, -1, -1};
    for (int p1 = 0; p1 < 7; p1++) {
      set<xyn>::iterator it2;
      it2 = S.find(xyn(x[num] + x_plus[p1], y[num] + y_plus[p1], -1));
      if (it2 == S.end()) continue;
      candidate.erase((*it2).num);
      int x_base = (*it2).x;
      int y_base = (*it2).y;
      int ok = 1;
      for (int plus = -1; plus <= 1; plus++) {
        set<xyn>::iterator it = S.find(xyn(x_base + plus, y_base + 1, -1));
        if (it == S.end()) continue;
        int xx = (*it).x;
        int yy = (*it).y;
        int cnt = 0;
        for (int p2 = -1; p2 <= 1; p2++)
          if (S.find(xyn(xx + p2, yy - 1, -1)) != S.end()) cnt++;
        if (cnt < 2) {
          ok = 0;
          break;
        }
      }
      if (ok) candidate.insert((*it2).num);
    }
    res = (1LL * res * m + num) % mmod;
  }
  cout << res << endl;
}
