#include <bits/stdc++.h>
using namespace std;
struct Cube {
  int first, second, no;
} cu[100005];
int n;
set<int> se;
map<pair<int, int>, int> mp;
bool check(int x, int y) {
  int flag = 0;
  if (mp.count(pair<int, int>(x + 1, y + 1))) {
    if (mp.count(pair<int, int>(x + 1, y)) ||
        mp.count(pair<int, int>(x + 2, y)))
      flag++;
  } else
    flag++;
  if (mp.count(pair<int, int>(x, y + 1))) {
    if (mp.count(pair<int, int>(x + 1, y)) ||
        mp.count(pair<int, int>(x - 1, y)))
      flag++;
  } else
    flag++;
  if (mp.count(pair<int, int>(x - 1, y + 1))) {
    if (mp.count(pair<int, int>(x - 1, y)) ||
        mp.count(pair<int, int>(x - 2, y)))
      flag++;
  } else
    flag++;
  return flag == 3;
}
void check2(int u) {
  int x = cu[u].first, y = cu[u].second;
  mp.erase(pair<int, int>(x, y));
  for (int i = -2; i <= 2; i++) {
    for (int j = -2; j <= 2; j++) {
      int tx = x + i, ty = y + j;
      if (mp.count(pair<int, int>(tx, ty))) {
        int tem = mp[pair<int, int>(tx, ty)];
        if (check(tx, ty)) {
          if (se.find(tem) == se.end()) se.insert(tem);
        } else {
          if (se.find(tem) != se.end()) se.erase(tem);
        }
      }
    }
  }
}
long long solve() {
  set<int>::iterator it;
  int flag = 1;
  long long ans = 0;
  while (!se.empty()) {
    if (flag) {
      it = --se.end();
      int i = *it;
      ans = (ans * n + i) % 1000000009;
      se.erase(it);
      check2(i);
      flag = !flag;
    } else {
      it = se.begin();
      int i = *it;
      ans = (ans * n + i) % 1000000009;
      se.erase(it);
      check2(i);
      flag = !flag;
    }
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &cu[i].first, &cu[i].second);
    cu[i].no = i;
    mp[pair<int, int>(cu[i].first, cu[i].second)] = i;
  }
  for (int i = 0; i < n; i++) {
    if (check(cu[i].first, cu[i].second)) se.insert(i);
  }
  long long ans = solve();
  printf("%I64d\n", ans);
}
