#include <bits/stdc++.h>
using namespace std;
int m;
int x[100000], y[100000];
map<pair<int, int>, int> ma;
int ans = 0;
vector<int> g[100000], rev[100000];
int indeg[100000] = {}, outdeg[100000] = {};
set<int> se;
int cnt[100000] = {};
bool used[100000] = {};
const int MOD = 1e9 + 9;
int main() {
  scanf("%d", &m);
  for (int i = 0; i < (int)(m); ++i) scanf("%d%d", x + i, y + i);
  for (int i = 0; i < (int)(m); ++i) ma[make_pair(x[i], y[i])] = i;
  for (int i = 0; i < (int)(m); ++i) {
    for (int j = -1; j <= 1; ++j) {
      auto it = ma.find(make_pair(x[i] + j, y[i] - 1));
      if (it != ma.end()) {
        g[i].push_back(it->second);
        rev[it->second].push_back(i);
        ++indeg[it->second];
        ++outdeg[i];
      }
    }
  }
  for (int i = 0; i < (int)(m); ++i)
    if (outdeg[i] == 1) ++cnt[g[i][0]];
  for (int i = 0; i < (int)(m); ++i)
    if (cnt[i] == 0) se.insert(i);
  bool maxim = true;
  while (!se.empty()) {
    int cur;
    if (maxim) {
      cur = *se.rbegin();
    } else {
      cur = *se.begin();
    }
    maxim = !maxim;
    se.erase(cur);
    used[cur] = true;
    ans = ((long long)ans * m + cur) % MOD;
    for (int x : rev[cur]) {
      if (--outdeg[x] == 1 && !used[x]) {
        for (int to : g[x]) {
          if (++cnt[to] == 1) {
            se.erase(to);
          }
        }
      }
    }
    if (outdeg[cur] == 1) {
      for (int to : g[cur])
        if (--cnt[to] == 0) {
          if (!used[to]) {
            se.insert(to);
          }
        }
    }
  }
  cout << ans << endl;
  return 0;
}
