#include <bits/stdc++.h>
using namespace std;
const int N = 100008, mod = 1e9 + 9;
int n;
map<pair<int, int>, int> flag;
long long ans, pw[N];
set<int> bst;
struct Node {
  int x, y;
} a[N];
int judge(int p) {
  int cnt = 0;
  for (int i = -1; i <= 1; i++)
    if (flag[make_pair(a[p].x + i, a[p].y - 1)]) cnt++;
  return cnt;
}
void Insert(int p) {
  int ok = 0;
  for (int i = -1; i <= 1; i++)
    if (flag[make_pair(a[p].x + i, a[p].y + 1)] &&
        judge(flag[make_pair(a[p].x + i, a[p].y + 1)]) == 1) {
      ok = 1;
      break;
    }
  if (!ok && !bst.count(p)) bst.insert(p);
  if (ok && bst.count(p)) bst.erase(p);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &a[i].x, &a[i].y);
    flag[make_pair(a[i].x, a[i].y)] = i;
  }
  for (int i = 1; i <= n; i++) Insert(i);
  for (int i = 1; i <= n; i++) {
    int x, y, p;
    if (i & 1)
      p = *bst.rbegin();
    else
      p = *bst.begin();
    ans = (ans * n + p - 1) % mod;
    bst.erase(p);
    x = a[p].x, y = a[p].y;
    flag[make_pair(x, y)] = 0;
    for (int j = -2; j <= 2; j++)
      for (int k = -2; k <= 2; k++)
        if (flag[make_pair(x + j, y + k)])
          Insert(flag[make_pair(x + j, y + k)]);
  }
  printf("%I64d\n", ans);
  return 0;
}
