#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
long long ans;
int m, n, x[100009], y[100009];
map<pair<int, int>, int> f;
set<int> s;
bool chk(int x, int y) {
  for (int i = -1; i <= 1; ++i)
    if (f.find(make_pair(x + i, y + 1)) != f.end()) {
      int j;
      for (j = -1; j <= 1; ++j) {
        if (i + j)
          if (f.find(make_pair(x + i + j, y)) != f.end()) {
            break;
          }
      }
      if (j <= 1)
        continue;
      else
        return false;
    }
  return true;
}
int main() {
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", x + i, y + i);
    f[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < m; ++i)
    if (chk(x[i], y[i])) s.insert(i);
  while (!s.empty()) {
    int t = n & 1 ? *s.begin() : *s.rbegin();
    s.erase(t);
    ++n;
    ans = (ans * m + t) % mod;
    f.erase(make_pair(x[t], y[t]));
    map<pair<int, int>, int>::iterator itr;
    for (int i = -2; i <= 2; ++i) {
      if ((itr = f.find(make_pair(x[t] + i, y[t]))) != f.end()) {
        if (!chk(x[t] + i, y[t])) s.erase(itr->second);
      }
    }
    for (int i = -1; i <= 1; ++i) {
      if ((itr = f.find(make_pair(x[t] + i, y[t] - 1))) != f.end()) {
        if (chk(x[t] + i, y[t] - 1)) s.insert(itr->second);
      }
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
