#include <bits/stdc++.h>
using namespace std;
const int maxm = 100000 + 100;
int m;
int x[maxm], y[maxm];
map<pair<int, int>, int> s;
set<int> leaves;
vector<int> num;
vector<int> holders[maxm];
vector<int> dep[maxm];
int main() {
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    s[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < m; i++) {
    if (s.find(make_pair(x[i] - 1, y[i] + 1)) != s.end()) {
      holders[s[make_pair(x[i] - 1, y[i] + 1)]].push_back(i);
      dep[i].push_back(s[make_pair(x[i] - 1, y[i] + 1)]);
    }
    if (s.find(make_pair(x[i], y[i] + 1)) != s.end()) {
      holders[s[make_pair(x[i], y[i] + 1)]].push_back(i);
      dep[i].push_back(s[make_pair(x[i], y[i] + 1)]);
    }
    if (s.find(make_pair(x[i] + 1, y[i] + 1)) != s.end()) {
      holders[s[make_pair(x[i] + 1, y[i] + 1)]].push_back(i);
      dep[i].push_back(s[make_pair(x[i] + 1, y[i] + 1)]);
    }
    if (dep[i].size() == 0) leaves.insert(i);
  }
  for (int i = 0; i < m; i++) {
    if (dep[i].size() == 0) continue;
    bool ok = true;
    for (int j = 0; j < dep[i].size(); j++) {
      if (holders[dep[i][j]].size() == 1) {
        ok = false;
        break;
      }
    }
    if (ok) leaves.insert(i);
  }
  int turn = 0;
  bool was[maxm] = {0};
  while (!leaves.empty()) {
    set<int>::iterator it;
    if (turn == 0) {
      it = --leaves.end();
    } else {
      it = leaves.begin();
    }
    int index = *it;
    leaves.erase(it);
    bool ok = true;
    if (dep[index].size() != 0) {
      for (int j = 0; j < dep[index].size(); j++) {
        if (holders[dep[index][j]].size() == 1) {
          ok = false;
          break;
        }
      }
      if (ok) {
        for (int j = 0; j < dep[index].size(); j++) {
          holders[dep[index][j]].erase(find(holders[dep[index][j]].begin(),
                                            holders[dep[index][j]].end(),
                                            index));
        }
      }
    }
    if (!ok) continue;
    num.push_back(index);
    was[index] = true;
    if (s.find(make_pair(x[index] - 1, y[index] - 1)) != s.end()) {
      int j = s[make_pair(x[index] - 1, y[index] - 1)];
      dep[j].erase(find(dep[j].begin(), dep[j].end(), index));
      if (!was[j]) {
        bool ok = true;
        for (int k = 0; k < dep[j].size(); k++) {
          if (holders[dep[j][k]].size() == 1) {
            ok = false;
            break;
          }
        }
        if (ok) leaves.insert(j);
      }
    }
    if (s.find(make_pair(x[index], y[index] - 1)) != s.end()) {
      int j = s[make_pair(x[index], y[index] - 1)];
      dep[j].erase(find(dep[j].begin(), dep[j].end(), index));
      if (!was[j]) {
        bool ok = true;
        for (int k = 0; k < dep[j].size(); k++) {
          if (holders[dep[j][k]].size() == 1) {
            ok = false;
            break;
          }
        }
        if (ok) leaves.insert(j);
      }
    }
    if (s.find(make_pair(x[index] + 1, y[index] - 1)) != s.end()) {
      int j = s[make_pair(x[index] + 1, y[index] - 1)];
      dep[j].erase(find(dep[j].begin(), dep[j].end(), index));
      if (!was[j]) {
        bool ok = true;
        for (int k = 0; k < dep[j].size(); k++) {
          if (holders[dep[j][k]].size() == 1) {
            ok = false;
            break;
          }
        }
        if (ok) leaves.insert(j);
      }
    }
    turn = 1 - turn;
  }
  const long long mod = (long long)1000000000 + 9;
  long long ans = 0;
  long long st = 1;
  for (int i = num.size() - 1; i >= 0; i--) {
    ans = (ans + num[i] * st) % mod;
    st = (st * m) % mod;
  }
  cout << ans << endl;
  return 0;
}
