#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 9;
map<pair<int, int>, int> h;
map<int, pair<int, int> > mishe1, mishe2;
vector<long long> L;
long long n;
int zir(int x, int y) {
  int jj = 0;
  for (int j = -1; j <= 1; j++)
    if (h.find(pair<int, int>(x + j, y - 1)) != h.end()) jj++;
  return jj;
}
int M(int x, int y) {
  for (int j = -1; j <= 1; j++) {
    if (h.find(pair<int, int>(x + j, y + 1)) == h.end()) continue;
    if (zir(x + j, y + 1) == 1) return 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    h[pair<int, int>(x, y)] = i;
  }
  for (map<pair<int, int>, int>::iterator i = h.begin(); i != h.end(); i++) {
    int x = i->first.first;
    int y = i->first.second;
    if (M(x, y)) {
      mishe1[i->second] = i->first;
      mishe2[-(i->second)] = i->first;
    }
  }
  int T = 1;
  while (mishe1.size()) {
    T++;
    pair<int, pair<int, int> > I;
    if (T % 2)
      I = *(mishe1.begin());
    else
      I = *(mishe2.begin());
    int x = I.second.first;
    int y = I.second.second;
    int II = abs(I.first);
    L.push_back(II);
    mishe1.erase(II);
    mishe2.erase(-II);
    h.erase(pair<int, int>(x, y));
    for (int j = -2; j <= 2; j++) {
      if (h.find(pair<int, int>(x + j, y)) == h.end()) continue;
      int Ii = h[pair<int, int>(x + j, y)];
      if (mishe1.find(Ii) == mishe1.end()) continue;
      if (M(x + j, y)) continue;
      mishe1.erase(Ii);
      mishe2.erase(-Ii);
    }
    for (int j = -1; j <= 1; j++) {
      if (h.find(pair<int, int>(x + j, y - 1)) == h.end()) continue;
      if (M(x + j, y - 1)) {
        pair<pair<int, int>, int> R = *(h.find(pair<int, int>(x + j, y - 1)));
        mishe1[R.second] = R.first;
        mishe2[-R.second] = R.first;
      }
    }
  }
  long long mm = 1;
  long long J = 0;
  for (int i = L.size() - 1; i >= 0; i--) {
    J = (J + L[i] * mm) % MOD;
    mm = (mm * n) % MOD;
  }
  cout << J << endl;
}
