#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
const int MAXN = 1000006;
vector<int> ANS;
pair<int, int> P[MAXN];
set<int> S;
map<pair<int, int>, int> M;
int numer(int a, int b) {
  typeof(M.begin()) it = M.find(pair<int, int>(a, b));
  if (it == M.end()) return -1;
  return it->second;
}
int nadole(int e) {
  int a = 0;
  for (int j = -1; j <= 1; ++j)
    a += numer(P[e].first + j, P[e].second - 1) != -1;
  ;
  return a;
}
bool wolne(int i) {
  for (int j = -1; j <= 1; ++j) {
    int e = numer(P[i].first + j, P[i].second + 1);
    ;
    if (e != -1 && nadole(e) == 1) return 0;
  }
  return 1;
}
void probuj(int first, int second) {
  int q = numer(first, second);
  ;
  if (q == -1) return;
  if (wolne(q)) {
    ;
    S.insert(q);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) scanf("%d%d", &P[i].first, &P[i].second);
  for (int i = 0; i < (n); ++i) M[P[i]] = i;
  for (int i = 0; i < (n); ++i)
    if (wolne(i)) S.insert(i);
  int ret = 0;
  for (int i = 0; i < (n); ++i) {
    int e;
    assert(S.size());
    if (i % 2 == 0)
      e = *(S.rbegin());
    else
      e = *(S.begin());
    S.erase(e);
    if (!wolne(e)) {
      --i;
      continue;
    };
    M[P[e]] = -1;
    for (int j = -1; j <= 1; ++j) probuj(P[e].first + j, P[e].second - 1);
    ret = (1LL * ret * n + e) % mod;
  }
  printf("%d\n", ret);
  return 0;
}
