#include <bits/stdc++.h>
using namespace std;
long long mypow(long long x, long long y) {
  long long ret = 1LL;
  while (y > 0LL) {
    if (y & 1LL) ret = (ret * x) % 1000000009;
    x = (x * x) % 1000000009;
    y >>= 1LL;
  }
  return ret;
}
int main() {
  int m;
  cin >> m;
  vector<int> x(m);
  vector<int> y(m);
  map<pair<int, int>, int> list_;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    list_[{x[i], y[i]}] = i;
  }
  vector<int> b(m);
  auto func = [&](int my_x, int my_y, int id) {
    if (my_y == 0) {
      b[id] = 3;
      return;
    }
    int cnt = 0;
    for (int dx = -1; dx <= 1; dx++) {
      auto itr = list_.find({my_x + dx, my_y - 1});
      if (itr != list_.end()) {
        cnt++;
      }
    }
    b[id] = cnt;
  };
  for (int i = 0; i < m; i++) {
    func(x[i], y[i], i);
  }
  vector<int> c(m);
  vector<set<int>> v(4);
  auto func__ = [&](int my_x, int my_y, int id) {
    int cnt = 100;
    for (int dx = -1; dx <= 1; dx++) {
      auto itr = list_.find({my_x + dx, my_y + 1});
      if (itr != list_.end()) {
        cnt = min(cnt, b[itr->second]);
      }
    }
    if (cnt == 100) {
      v[0].insert(id);
      c[id] = 0;
    } else {
      v[cnt].insert(id);
      c[id] = cnt;
    }
  };
  for (int i = 0; i < m; i++) {
    func__(x[i], y[i], i);
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    long long block = -1;
    vector<pair<int, int>> cand;
    int at;
    if ((i & 1) == 0) {
      if (v[0].size() > 0) cand.push_back({*v[0].rbegin(), 0});
      if (v[2].size() > 0) cand.push_back({*v[2].rbegin(), 2});
      if (v[3].size() > 0) cand.push_back({*v[3].rbegin(), 3});
      at = max_element(cand.begin(), cand.end()) - cand.begin();
    } else {
      if (v[0].size() > 0) cand.push_back({*v[0].begin(), 0});
      if (v[2].size() > 0) cand.push_back({*v[2].begin(), 2});
      if (v[3].size() > 0) cand.push_back({*v[3].begin(), 3});
      at = min_element(cand.begin(), cand.end()) - cand.begin();
    }
    v[cand[at].second].erase(cand[at].first);
    block = cand[at].first;
    list_.erase({x[block], y[block]});
    for (int dy = -2; dy <= 2; dy++) {
      for (int dx = -2; dx <= 2; dx++) {
        auto itr = list_.find({x[block] + dx, y[block] + dy});
        if (itr != list_.end()) {
          v[c[itr->second]].erase(itr->second);
        }
      }
    }
    for (int dy = -2; dy <= 2; dy++) {
      for (int dx = -2; dx <= 2; dx++) {
        auto itr = list_.find({x[block] + dx, y[block] + dy});
        if (itr != list_.end()) {
          func(x[itr->second], y[itr->second], itr->second);
        }
      }
    }
    for (int dy = -2; dy <= 2; dy++) {
      for (int dx = -2; dx <= 2; dx++) {
        auto itr = list_.find({x[block] + dx, y[block] + dy});
        if (itr != list_.end()) {
          func__(x[itr->second], y[itr->second], itr->second);
        }
      }
    }
    ans += (block * mypow(m, m - (i + 1))) % 1000000009;
    ans %= 1000000009;
  }
  cout << ans % 1000000009 << endl;
  return 0;
}
