#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
map<pair<int, int>, int> mapa;
pair<int, int> arr[100005];
int indeg[100005], outdeg[100005];
bool gone[100005];
bool ok(int x) {
  bool yes = true;
  for (int dx = -1; dx <= 1; ++dx) {
    int nx = arr[x].first + dx;
    int ny = arr[x].second + 1;
    map<pair<int, int>, int>::iterator it = mapa.find(pair<int, int>(nx, ny));
    if (it != mapa.end()) {
      yes &= outdeg[it->second] > 1 || gone[it->second] ||
             arr[it->second].second == 0;
    }
  }
  return yes;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &arr[i].first, &arr[i].second);
    mapa[pair<int, int>(arr[i].first, arr[i].second)] = i;
  }
  for (int i = 0; i < n; ++i) {
    for (int dx = -1; dx <= 1; ++dx) {
      int nx = arr[i].first + dx;
      int ny = arr[i].second - 1;
      map<pair<int, int>, int>::iterator it = mapa.find(pair<int, int>(nx, ny));
      if (it != mapa.end()) {
        ++indeg[it->second];
        ++outdeg[i];
      }
    }
  }
  set<int> s;
  for (int i = 0; i < n; ++i) {
    if (ok(i)) {
      s.insert(i);
    }
  }
  int turn = 0;
  long long ans = 0;
  for (int taken = 0; taken < n;) {
    int v;
    if (turn)
      v = *s.begin();
    else
      v = *s.rbegin();
    s.erase(v);
    if (!ok(v)) continue;
    ++taken;
    gone[v] = true;
    for (int dx = -1; dx <= 1; ++dx) {
      {
        int nx = arr[v].first + dx;
        int ny = arr[v].second - 1;
        map<pair<int, int>, int>::iterator it =
            mapa.find(pair<int, int>(nx, ny));
        if (it != mapa.end() && !gone[it->second]) {
          --outdeg[v];
          --indeg[it->second];
        }
      }
      {
        int nx = arr[v].first + dx;
        int ny = arr[v].second + 1;
        map<pair<int, int>, int>::iterator it =
            mapa.find(pair<int, int>(nx, ny));
        if (it != mapa.end() && !gone[it->second]) {
          --indeg[v];
          --outdeg[it->second];
        }
      }
    }
    for (int dx = -1; dx <= 1; ++dx) {
      int nx = arr[v].first + dx;
      int ny = arr[v].second - 1;
      map<pair<int, int>, int>::iterator it = mapa.find(pair<int, int>(nx, ny));
      if (it != mapa.end()) {
        if (ok(it->second) && !gone[it->second]) s.insert(it->second);
      }
    }
    ans = ((ans * n) % mod + v) % mod;
    turn = 1 - turn;
  }
  cout << ans << "\n";
  return 0;
}
