#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> m;
inline int count(int x, int y) {
  return m.count(make_pair(x, y))
             ? m.count(make_pair(x - 1, y - 1)) + m.count(make_pair(x, y - 1)) +
                   m.count(make_pair(x + 1, y - 1))
             : 3;
}
int n, x[111111], y[111111];
set<int> s;
void insert(int a, int b) {
  if (!m.count(make_pair(a, b))) return;
  int id = m[make_pair(a, b)];
  if (!s.count(id) && count(a - 1, b + 1) > 1 && count(a, b + 1) > 1 &&
      count(a + 1, b + 1) > 1)
    s.insert(id);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", x + i, y + i);
    m[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < n; i++) insert(x[i], y[i]);
  long long ans = 0;
  for (int i = 1; !s.empty(); i ^= 1) {
    int j;
    for (;;) {
      set<int>::iterator it;
      if (i)
        it = --s.end();
      else
        it = s.begin();
      j = *it;
      s.erase(it);
      if (count(x[j] - 1, y[j] + 1) > 1 && count(x[j], y[j] + 1) > 1 &&
          count(x[j] + 1, y[j] + 1) > 1)
        break;
    }
    m.erase(make_pair(x[j], y[j]));
    insert(x[j] - 1, y[j] - 1);
    insert(x[j], y[j] - 1);
    insert(x[j] + 1, y[j] - 1);
    ans = (ans * n + j) % 1000000009;
  }
  printf("%lld\n", ans);
  return 0;
}
