#include <bits/stdc++.h>
using namespace std;
int mod = 1000000009;
map<pair<int, int>, int> mp;
set<pair<int, pair<int, int> >, greater<pair<int, pair<int, int> > > > s;
vector<int> v(100005);
int ind, X, Y;
bool check(int x, int y) { return s.find({mp[{x, y}], {x, y}}) != s.end(); }
bool checkmp(pair<int, int> t) {
  int x = t.first, y = t.second;
  return (mp.find({x, y}) != mp.end() && mp.find({x, y})->second);
}
void release(int x, int y, int val) {
  v[ind--] = val - 1;
  if (checkmp({x - 1, y - 1})) {
    X = x - 1, Y = y - 1;
    if ((!checkmp({X - 1, Y + 1}) ||
         ((checkmp({X - 1, Y}) || checkmp({X - 2, Y})))) &&
        (!checkmp({X, Y + 1}) ||
         ((checkmp({X - 1, Y}) || checkmp({X + 1, Y})))) &&
        (!checkmp({X + 1, Y + 1}) || (checkmp({X + 1, Y})) ||
         checkmp({X + 2, Y})))
      s.insert({mp[{x - 1, y - 1}], {x - 1, y - 1}});
  }
  if (checkmp({x + 1, y - 1})) {
    X = x + 1, Y = y - 1;
    if ((!checkmp({X - 1, Y + 1}) ||
         ((checkmp({X - 1, Y}) || checkmp({X - 2, Y})))) &&
        (!checkmp({X, Y + 1}) ||
         ((checkmp({X - 1, Y}) || checkmp({X + 1, Y})))) &&
        (!checkmp({X + 1, Y + 1}) || (checkmp({X + 1, Y})) ||
         checkmp({X + 2, Y})))
      s.insert({mp[{x + 1, y - 1}], {x + 1, y - 1}});
  }
  if (checkmp({x, y - 1})) {
    X = x, Y = y - 1;
    if ((!checkmp({X - 1, Y + 1}) ||
         ((checkmp({X - 1, Y}) || checkmp({X - 2, Y})))) &&
        (!checkmp({X, Y + 1}) ||
         ((checkmp({X - 1, Y}) || checkmp({X + 1, Y})))) &&
        (!checkmp({X + 1, Y + 1}) || (checkmp({X + 1, Y})) ||
         checkmp({X + 2, Y})))
      s.insert({mp[{x, y - 1}], {x, y - 1}});
  }
  if (checkmp({x + 1, y + 1}) &&
      (checkmp({x + 2, y}) && !checkmp({x + 1, y}))) {
    if (check(x + 2, y)) s.erase({mp[{x + 2, y}], {x + 2, y}});
  }
  if (checkmp({x + 1, y + 1}) &&
      (!checkmp({x + 2, y}) && checkmp({x + 1, y}))) {
    if (check(x + 1, y)) s.erase({mp[{x + 1, y}], {x + 1, y}});
  }
  if (checkmp({x - 1, y + 1}) &&
      (checkmp({x - 2, y}) && !checkmp({x - 1, y}))) {
    if (check(x - 2, y)) s.erase({mp[{x - 2, y}], {x - 2, y}});
  }
  if (checkmp({x - 1, y + 1}) &&
      (!checkmp({x - 2, y}) && checkmp({x - 1, y}))) {
    if (check(x - 1, y)) s.erase({mp[{x - 1, y}], {x - 1, y}});
  }
  if (checkmp({x, y + 1}) && (checkmp({x + 1, y}) && !checkmp({x - 1, y}))) {
    if (check(x + 1, y)) s.erase({mp[{x + 1, y}], {x + 1, y}});
  }
  if (checkmp({x, y + 1}) && (!checkmp({x + 1, y}) && checkmp({x - 1, y}))) {
    if (check(x - 1, y)) s.erase({mp[{x - 1, y}], {x - 1, y}});
  }
}
int p(int a, int p) {
  int ret = 1;
  while (p) {
    if (p & 1) ret = 1LL * ret * a % mod;
    a = 1LL * a * a % mod;
    p >>= 1;
  }
  return ret;
}
int a[27];
int main() {
  int n, x, y, val;
  scanf("%d", &n);
  ind = n - 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x, &y);
    mp[{x, y}] = i + 1;
  }
  int cnt = 0;
  for (map<pair<int, int>, int>::iterator it = mp.begin(); it != mp.end();
       ++it) {
    x = it->first.first;
    y = it->first.second;
    val = it->second;
    if (checkmp({x, y + 1}) || checkmp({x - 1, y + 1}) ||
        checkmp({x + 1, y + 1})) {
      if ((!checkmp({x - 1, y + 1}) ||
           ((checkmp({x - 1, y}) || checkmp({x - 2, y})))) &&
          (!checkmp({x, y + 1}) ||
           ((checkmp({x - 1, y}) || checkmp({x + 1, y})))) &&
          (!checkmp({x + 1, y + 1}) || (checkmp({x + 1, y})) ||
           checkmp({x + 2, y}))) {
        s.insert({val, {x, y}});
      }
    } else {
      s.insert({val, {x, y}});
    }
  }
  while (!s.empty()) {
    auto it = s.begin();
    x = it->second.first;
    y = it->second.second;
    val = it->first;
    mp[{x, y}] = 0;
    s.erase(it);
    release(x, y, val);
    if (s.size()) {
      auto it = s.end();
      it--;
      x = it->second.first;
      y = it->second.second;
      val = it->first;
      mp[{x, y}] = 0;
      s.erase(it);
      release(x, y, val);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = (ans + 1LL * v[i] * p(n, i)) % mod;
  }
  cout << ans << endl;
}
