#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> cube[100010];
map<pair<int, int>, int> M;
set<int> S;
bool check[100001];
int order[100001], up_cnt[100001], lo_cnt[100001];
vector<int> upper[100001], lower[100001];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &cube[i].first, &cube[i].second);
    M[make_pair(cube[i].first, cube[i].second)] = i;
  }
  for (int i = 0; i < n; i++) {
    S.insert(i);
    auto it = M.find(make_pair(cube[i].first - 1, cube[i].second - 1));
    if (it != M.end()) lower[i].push_back(it->second);
    it = M.find(make_pair(cube[i].first, cube[i].second - 1));
    if (it != M.end()) lower[i].push_back(it->second);
    it = M.find(make_pair(cube[i].first + 1, cube[i].second - 1));
    if (it != M.end()) lower[i].push_back(it->second);
    it = M.find(make_pair(cube[i].first - 1, cube[i].second + 1));
    if (it != M.end()) upper[i].push_back(it->second);
    it = M.find(make_pair(cube[i].first, cube[i].second + 1));
    if (it != M.end()) upper[i].push_back(it->second);
    it = M.find(make_pair(cube[i].first + 1, cube[i].second + 1));
    if (it != M.end()) upper[i].push_back(it->second);
    up_cnt[i] = upper[i].size();
    lo_cnt[i] = lower[i].size();
  }
  for (int i = 0; i < n; i++) {
    if (!(i & 1)) {
      while (1) {
        auto it = S.end();
        it--;
        int j, t = *it;
        S.erase(it);
        for (j = 0; j < upper[t].size(); j++) {
          if (check[upper[t][j]]) continue;
          if (lo_cnt[upper[t][j]] == 1) break;
        }
        if (j == upper[t].size()) {
          order[i] = t;
          break;
        }
      }
    } else {
      while (1) {
        auto it = S.begin();
        int j, t = *it;
        S.erase(it);
        for (j = 0; j < upper[t].size(); j++) {
          if (check[upper[t][j]]) continue;
          if (lo_cnt[upper[t][j]] == 1) break;
        }
        if (j == upper[t].size()) {
          order[i] = t;
          break;
        }
      }
    }
    int t = order[i];
    check[t] = 1;
    for (int j = 0; j < upper[t].size(); j++) {
      if (check[upper[t][j]]) continue;
      lo_cnt[upper[t][j]]--;
    }
    for (int j = 0; j < lower[t].size(); j++) {
      if (check[lower[t][j]]) continue;
      S.insert(lower[t][j]);
    }
  }
  long long gob = 1, print = 0;
  for (int i = n - 1; i >= 0; i--) {
    print += gob * order[i];
    print %= 1000000009;
    gob *= n;
    gob %= 1000000009;
  }
  printf("%I64d\n", print);
  return 0;
}
