#include <bits/stdc++.h>
using namespace std;
void remove(vector<int>& v, int e) {
  for (int i = 0; i < v.size(); i++)
    if (v[i] == e) {
      swap(v[i], v.back());
      v.pop_back();
      return;
    }
}
bool eligible(vector<vector<int>>& g, vector<vector<int>>& gt, int v) {
  for (int neigh : g[v])
    if (gt[neigh].size() == 1) return false;
  return true;
}
vector<int> doit(vector<vector<int>>& g, vector<vector<int>>& gt) {
  vector<int> result;
  set<int> taken;
  set<int> q;
  bool max_turn = true;
  for (int i = 0; i < g.size(); i++) {
    if (eligible(g, gt, i)) {
      q.insert(i);
    }
  }
  while (result.size() < g.size()) {
    assert(q.size());
    int next = -1;
    if (max_turn) {
      next = *q.rbegin();
    } else {
      next = *q.begin();
    }
    q.erase(next);
    if (!eligible(g, gt, next) || taken.count(next)) continue;
    result.push_back(next);
    taken.insert(next);
    for (int fneigh : g[next]) {
      remove(gt[fneigh], next);
      if (eligible(g, gt, fneigh)) q.insert(fneigh);
    }
    for (int bneigh : gt[next]) {
      remove(g[bneigh], next);
      if (eligible(g, gt, bneigh)) q.insert(bneigh);
    }
    max_turn = !max_turn;
  }
  return result;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  vector<vector<int>> gt(n);
  map<pair<int, int>, int> numbers;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    numbers[make_pair(x, y)] = i;
  }
  for (const auto& it : numbers) {
    for (int xx = it.first.first - 1; xx <= it.first.first + 1; xx++) {
      pair<int, int> neighbor(xx, it.first.second + 1);
      if (numbers.count(neighbor)) {
        g[it.second].push_back(numbers[neighbor]);
        gt[numbers[neighbor]].push_back(it.second);
      }
    }
  }
  vector<int> ans = doit(g, gt);
  long long ans_dec = 0;
  for (int i = 0; i < ans.size(); i++) {
    ans_dec *= n;
    ans_dec += ans[i];
    ans_dec %= 1000000000 + 9;
  }
  cout << ans_dec << endl;
  return 0;
}
