#include <bits/stdc++.h>
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
const long long MOD = 1000000009;
const int MAXM = 100010;
int m;
long long pow_mod[MAXM];
int X[MAXM], Y[MAXM];
map<pair<int, int>, int> ma;
set<int> S;
set<int> up[MAXM], down[MAXM];
void init() {
  pow_mod[0] = 1;
  for (int i = 1; i < m; i++) {
    pow_mod[i] = (pow_mod[i - 1] * m) % MOD;
  }
}
bool ok(int k) {
  for (auto el : up[k]) {
    if (down[el].size() <= 1) return false;
  }
  return true;
}
int main() {
  cin >> m;
  init();
  for (int i = 0; i < m; i++) {
    cin >> X[i] >> Y[i];
    ma.insert(make_pair(pair<int, int>(X[i], Y[i]), i));
  }
  for (auto el : ma) {
    int y = el.first.second;
    int x = el.first.first;
    for (int d = -1; d <= 1; d++) {
      pair<int, int> tmp = pair<int, int>(x + d, y + 1);
      if (ma.count(tmp)) {
        up[el.second].insert(ma[tmp]);
        down[ma[tmp]].insert(el.second);
      }
    }
  }
  for (int i = 0; i < m; i++)
    if (ok(i)) S.insert(i);
  long long ret = 0;
  for (int i = 0; i < m; i++) {
    int er;
    if (i % 2 == 0) {
      er = *S.rbegin();
    } else {
      er = *S.begin();
    }
    ret += pow_mod[m - i - 1] * (long long)er % MOD;
    ret %= MOD;
    S.erase(er);
    for (auto el : up[er]) {
      down[el].erase(er);
      if (ok(el))
        S.insert(el);
      else
        S.erase(el);
      for (auto ell : down[el]) {
        if (ok(ell))
          S.insert(ell);
        else
          S.erase(ell);
      }
    }
    for (auto el : down[er]) {
      up[el].erase(er);
      if (ok(el))
        S.insert(el);
      else
        S.erase(el);
    }
  }
  cout << ret << endl;
  return 0;
}
