#include <bits/stdc++.h>
using namespace std;
long long m;
pair<long long, long long> a[100005];
map<pair<long long, long long>, pair<long long, long long> > ord;
set<long long> s;
bool used[100005];
vector<long long> result;
bool Removechild(pair<long long, long long> p) {
  if (!ord.count(p)) return true;
  if (p.first == 0) return true;
  long long count = 0;
  for (long long i = -1; i <= 1; i++) {
    pair<long long, long long> child = make_pair(p.first - 1, p.second + i);
    if (ord.count(child) && !used[ord[child].first]) count++;
  }
  if (count == 0 || count == 1) return false;
  return true;
}
bool Remove(pair<long long, long long> p) {
  if (!ord.count(p)) return false;
  bool result = true;
  for (long long i = -1; i <= 1; i++) {
    pair<long long, long long> parent = make_pair(p.first + 1, p.second + i);
    if (ord.count(parent) && !used[ord[parent].first])
      result = result && Removechild(parent);
  }
  return result;
}
long long Convert() {
  long long fact = 1;
  long long r = 0;
  for (long long i = result.size() - 1; i >= 0; i--) {
    r = (r + ((result[i]) * fact) % 1000000009) % 1000000009;
    fact = (fact * m) % 1000000009;
  }
  return r;
}
int main() {
  cin >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a[i].second >> a[i].first;
    ord[a[i]] = make_pair(i, 0);
  }
  for (long long i = 0; i < m; i++) {
    if (Remove(a[i])) s.insert(ord[a[i]].first);
  }
  long long ind = 0;
  while (!s.empty()) {
    long long cur;
    if (ind % 2 == 1) {
      cur = *s.begin();
      s.erase(s.begin());
    } else {
      cur = *s.rbegin();
      set<long long>::iterator it = s.end();
      --it;
      s.erase(it);
    }
    used[cur] = true;
    result.push_back(cur);
    for (long long i = -1; i <= 1; i++) {
      pair<long long, long long> p =
          make_pair(a[cur].first - 1, a[cur].second + i);
      if (ord.count(p) && !used[ord[p].first] && Remove(p))
        s.insert(ord[p].first);
    }
    for (long long i = -2; i <= 2; i++) {
      pair<long long, long long> p = make_pair(a[cur].first, a[cur].second + i);
      if (ord.count(p) && !used[ord[p].first] && !Remove(p))
        s.erase(ord[p].first);
    }
    ind++;
  }
  cout << Convert() << endl;
}
