#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
long long f[100010];
struct node {
  int x, y, t;
  node(int x, int y, int t) : x(x), y(y), t(t) {}
  bool operator<(const node& a) const {
    return x < a.x || (x == a.x && y < a.y);
  }
};
set<node> s;
struct cmp1 {
  bool operator()(const node& a, const node& b) { return a.t < b.t; }
};
struct cmp2 {
  bool operator()(const node& a, const node& b) { return a.t > b.t; }
};
priority_queue<node, vector<node>, cmp1> big;
priority_queue<node, vector<node>, cmp2> small;
inline bool stable(const node& t) {
  if (!s.count(t)) {
    return 1;
  }
  int flag = s.count(node(t.x - 1, t.y - 1, 0)) ||
             s.count(node(t.x, t.y - 1, 0)) ||
             s.count(node(t.x + 1, t.y - 1, 0));
  return flag;
}
inline bool canmove(const node& t) {
  if (!s.erase(t)) {
    return 0;
  }
  bool flag = stable(node(t.x - 1, t.y + 1, 0)) &&
              stable(node(t.x, t.y + 1, 0)) &&
              stable(node(t.x + 1, t.y + 1, 0));
  s.insert(t);
  return flag;
}
int main() {
  int i, n;
  scanf("%d", &n);
  f[0] = 1;
  for (i = 1; i < n; i++) f[i] = f[i - 1] * n % mod;
  for (i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    s.insert(node(x, y, i));
  }
  for (set<node>::iterator it = s.begin(); it != s.end();) {
    set<node>::iterator jt = it;
    ++jt;
    node tmp = *it;
    if (canmove(tmp)) {
      big.push(tmp);
      small.push(tmp);
    }
    it = jt;
  }
  long long ans = 0;
  node u = node(0, 0, 0);
  node v = node(0, 0, 0);
  for (i = n - 1; i >= 0; i--) {
    if ((n - i) & 1) {
      while (!big.empty()) {
        u = big.top();
        big.pop();
        if (canmove(u)) {
          break;
        }
      }
    } else {
      while (!small.empty()) {
        u = small.top();
        small.pop();
        if (canmove(u)) {
          break;
        }
      }
    }
    s.erase(u);
    ans = (ans + u.t * f[i] % mod) % mod;
    set<node>::iterator it = s.find(node(u.x - 1, u.y - 1, 0));
    if (it != s.end() && canmove(v = *it)) {
      big.push(v);
      small.push(v);
    }
    it = s.find(node(u.x, u.y - 1, 0));
    if (it != s.end() && canmove(v = *it)) {
      big.push(v);
      small.push(v);
    }
    it = s.find(node(u.x + 1, u.y - 1, 0));
    if (it != s.end() && canmove(v = *it)) {
      big.push(v);
      small.push(v);
    }
  }
  cout << ans << endl;
  return 0;
}
