#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, int> m;
pair<long long, long long> pos[112345];
set<int> down[112345];
set<int> up[112345];
int dx[] = {-1, 0, 1};
bool puedosacar(int i) {
  for (auto x : up[i])
    if (down[x].size() == 1) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (int i = (0); i < (n); i++) {
    int x, y;
    cin >> x >> y;
    m[{x, y}] = i;
    pos[i] = {x, y};
  }
  for (int i = (0); i < (n); i++) {
    auto p = pos[i];
    int x = p.first, y = p.second;
    for (int k = (0); k < (3); k++) {
      if (m.count({x + dx[k], y - 1})) {
        int u = m[{x + dx[k], y - 1}];
        down[i].insert(u);
        up[u].insert(i);
      }
    }
  }
  set<int> sacar;
  for (int i = (0); i < (n); i++)
    if (puedosacar(i)) sacar.insert(i);
  int t = 0;
  long long res = 0;
  while (sacar.size()) {
    long long act;
    if ((t & 1) == 0) {
      auto it = sacar.end();
      --it;
      act = *it;
    } else {
      act = *sacar.begin();
    }
    sacar.erase(act);
    for (auto x : down[act]) {
      up[x].erase(act);
      if (puedosacar(x)) sacar.insert(x);
    }
    for (auto x : up[act]) {
      down[x].erase(act);
      if (down[x].size() == 1) {
        auto y = *down[x].begin();
        sacar.erase(y);
      }
    }
    res *= n;
    res %= 1000000009;
    res += act;
    res %= 1000000009;
    t = 1 - t;
  }
  cout << res << endl;
  return 0;
}
