#include <bits/stdc++.h>
using namespace std;
map<int, map<int, int> > p;
int n, x[100005], y[100005], M = 1e9 + 9;
bitset<100005> es;
priority_queue<int> mx;
priority_queue<int, vector<int>, greater<int> > mn;
long long pot(long long b, int p, int m) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res *= b;
      res %= m;
    }
    b *= b;
    b %= m;
    p /= 2;
  }
  return res;
}
bool exis(int x, int y) {
  map<int, map<int, int> >::iterator v = p.find(x);
  if (v == p.end()) return false;
  map<int, int>::iterator u = v->second.find(y);
  if (u == v->second.end()) return false;
  return es[u->second];
}
bool esPos(int x, int y) {
  bool res = true;
  for (int i = -1; i <= 1; i++)
    if (exis(x + i, y + 1)) {
      bool f = false;
      for (int j = -1; j <= 1; j++) {
        if (i != -j) f |= exis(x + j + i, y);
      }
      res &= f;
    }
  return res;
}
void init() {
  for (int i = 0; i < n; i++)
    if (esPos(x[i], y[i])) {
      mx.push(i);
      mn.push(i);
    }
}
long long obtRes() {
  init();
  bool t = true;
  int i, pt = n - 1;
  long long res = 0;
  while (es.count()) {
    if (t) {
      while (!es[(i = mx.top())] || !esPos(x[i], y[i])) mx.pop();
      mx.pop();
    } else {
      while (!es[(i = mn.top())] || !esPos(x[i], y[i])) mn.pop();
      mn.pop();
    }
    res += i * pot(n, pt, M);
    res %= M;
    es[i] = 0;
    if (y) {
      for (int j = -1; j <= 1; j++) {
        if (exis(x[i] + j, y[i] - 1) && esPos(x[i] + j, y[i] - 1)) {
          int xd = p[x[i] + j][y[i] - 1];
          mx.push(xd);
          mn.push(xd);
        }
      }
    }
    t = !t;
    pt--;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    p[x[i]][y[i]] = i;
    es[i] = 1;
  }
  cout << obtRes() << '\n';
  return 0;
}
