#include <bits/stdc++.h>
using namespace std;
int n;
int x[100010], y[100010];
map<pair<int, int>, int> f;
set<int> g;
long long ans;
bool yes(int tmp) {
  int X, Y;
  X = x[tmp] + 1;
  Y = y[tmp] + 1;
  if (f.count((make_pair(X, Y)))) {
    if (!f.count((make_pair(X, Y - 1))) &&
        !f.count((make_pair(X + 1, Y - 1)))) {
      return false;
    }
  }
  X = x[tmp];
  Y = y[tmp] + 1;
  if (f.count((make_pair(X, Y)))) {
    if (!f.count((make_pair(X - 1, Y - 1))) &&
        !f.count((make_pair(X + 1, Y - 1)))) {
      return false;
    }
  }
  X = x[tmp] - 1;
  Y = y[tmp] + 1;
  if (f.count((make_pair(X, Y)))) {
    if (!f.count((make_pair(X - 1, Y - 1))) &&
        !f.count((make_pair(X, Y - 1)))) {
      return false;
    }
  }
  return true;
}
void add(int tmp) {
  int X, Y;
  X = x[tmp] - 1;
  Y = y[tmp] - 1;
  if (f.count((make_pair(X, Y)))) {
    int u = f[(make_pair(X, Y))];
    if (yes(u)) g.insert(u);
  }
  X = x[tmp];
  Y = y[tmp] - 1;
  if (f.count((make_pair(X, Y)))) {
    int u = f[(make_pair(X, Y))];
    if (yes(u)) g.insert(u);
  }
  X = x[tmp] + 1;
  Y = y[tmp] - 1;
  if (f.count((make_pair(X, Y)))) {
    int u = f[(make_pair(X, Y))];
    if (yes(u)) g.insert(u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
    f[(make_pair(x[i], y[i]))] = i;
  }
  for (int i = 0; i < n; i++) {
    if (yes(i)) g.insert(i);
  }
  for (int i = 0; i < n; i++) {
    if (i & 1) {
      while (!g.empty()) {
        int tmp = (*g.begin());
        if (yes(tmp)) {
          ans = ((ans * n % 1000000009) + tmp) % 1000000009;
          g.erase(tmp);
          f.erase((make_pair(x[tmp], y[tmp])));
          add(tmp);
          break;
        }
        g.erase(tmp);
      }
    } else {
      while (!g.empty()) {
        int tmp = (*g.rbegin());
        if (yes(tmp)) {
          ans = ((ans * n % 1000000009) + tmp) % 1000000009;
          g.erase(tmp);
          f.erase((make_pair(x[tmp], y[tmp])));
          add(tmp);
          break;
        }
        g.erase(tmp);
      }
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
