#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
map<pair<int, int>, int> h;
int x[100000], y[100000];
bool visit[100000];
bool istrue(int ind) {
  if (visit[ind]) return false;
  bool flag = true;
  int i, j;
  for (i = -1; i < 2; ++i)
    if (h.count(make_pair(x[ind] + i, y[ind] + 1))) {
      flag = false;
      for (j = -1; j < 2; ++j)
        if (i + j != 0) {
          if (h.count(make_pair(x[ind] + i + j, y[ind]))) flag = true;
        }
      if (!flag) return false;
    }
  return true;
}
int main() {
  int cur, m, i, next;
  cin >> m;
  for (i = 0; i < m; ++i) {
    cin >> x[i] >> y[i];
    h[make_pair(x[i], y[i])] = i;
  }
  set<int> s;
  for (i = 0; i < m; ++i)
    if (istrue(i)) s.insert(i);
  int ff = 1;
  long long ret = 0;
  while (!s.empty()) {
    if (ff)
      cur = *s.rbegin();
    else
      cur = *s.begin();
    s.erase(cur);
    if (!istrue(cur)) continue;
    ff ^= 1;
    h.erase(make_pair(x[cur], y[cur]));
    ret = (ret * m + cur) % mod;
    for (i = -1; i < 2; ++i)
      if (h.count(make_pair(x[cur] + i, y[cur] - 1)))
        if (istrue((next = h[make_pair(x[cur] + i, y[cur] - 1)])))
          s.insert(next);
  }
  cout << ret << endl;
}
