#include <bits/stdc++.h>
using namespace std;
int x[100000], y[100000];
set<int> s;
map<pair<int, int>, int> m;
bool mark[100000];
bool slobo(int t) {
  for (int i = 0; i < 3; i++) {
    int h = m[make_pair(x[t] + i - 1, y[t] + 1)] - 1;
    if (h >= 0 && !mark[h]) {
      int ret = 0;
      for (int j = 0; j < 3; j++) {
        int h = m[make_pair(x[t] + i - 1 + j - 1, y[t])] - 1;
        if (h >= 0 && !mark[h]) ret++;
      }
      if (ret == 1) return false;
    }
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    m[make_pair(x[i], y[i])] = i + 1;
  }
  for (int i = 0; i < n; i++)
    if (slobo(i)) s.insert(i);
  long long res = 0, trn = 0;
  while (s.size()) {
    int t;
    if (trn % 2 == 0)
      t = *s.rbegin();
    else
      t = *s.begin();
    s.erase(t);
    if (!slobo(t)) continue;
    trn++;
    mark[t] = true;
    res = (res * n + t) % 1000000009;
    for (int i = 0; i < 3; i++) {
      int h = m[make_pair(x[t] + i - 1, y[t] + -1)] - 1;
      if (h >= 0 && slobo(h) && !mark[h]) s.insert(h);
    }
  }
  cout << res << endl;
  return 0;
}
