#include <bits/stdc++.h>
using namespace std;
void deba(int* a, int n) {
  cerr << "| ";
  for (int i = 0; i < (n); i++) cerr << a[i] << " ";
  cerr << "|" << endl;
}
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 30;
int mod = 1000000009;
int MIL = 1000000;
map<long long, int> all;
map<long long, int>::iterator it;
set<int> volne;
set<int>::iterator itv;
long long arr[100005];
vector<long long int> gf[100005];
vector<long long int> gs[100005];
int main() {
  int n;
  scanf("%d", &n);
  ;
  for (int i = 0; i < (n); i++) {
    long long int a, b;
    scanf("%d %d", &a, &b);
    ;
    arr[i] = a * MIL + b;
    all.insert(make_pair(arr[i], i));
  }
  for (int i = 0; i < (n); i++) {
    if ((it = all.find(arr[i] + 1 + MIL)) != all.end())
      gf[i].push_back(it->second);
    if ((it = all.find(arr[i] + 1 - MIL)) != all.end())
      gf[i].push_back(it->second);
    if ((it = all.find(arr[i] + 1)) != all.end()) gf[i].push_back(it->second);
    if ((it = all.find(arr[i] - 1 + MIL)) != all.end()) {
      gs[i].push_back(it->second);
    }
    if ((it = all.find(arr[i] - 1 - MIL)) != all.end()) {
      gs[i].push_back(it->second);
    }
    if ((it = all.find(arr[i] - 1)) != all.end()) {
      gs[i].push_back(it->second);
    }
  }
  for (int i = 0; i < (n); i++) {
    bool fre = true;
    for (int j = 0; j < (gf[i].size()); j++) {
      if (gs[gf[i][j]].size() <= 1) fre = false;
    }
    if (fre) {
      volne.insert(i);
    }
  }
  vector<long long int> res;
  for (int k = 0; k < (n); k++) {
    if (k % 2 == 0) {
      itv = volne.end();
      itv--;
    } else {
      itv = volne.begin();
    }
    int num = *itv;
    res.push_back(num);
    for (int j = 0; j < (gf[num].size()); j++) {
      for (int m = 0; m < (gs[gf[num][j]].size()); m++)
        if (gs[gf[num][j]][m] == num)
          gs[gf[num][j]].erase(gs[gf[num][j]].begin() + m);
    }
    for (int j = 0; j < (gs[num].size()); j++) {
      for (int m = 0; m < (gf[gs[num][j]].size()); m++)
        if (gf[gs[num][j]][m] == num) {
          gf[gs[num][j]].erase(gf[gs[num][j]].begin() + m);
          int i = gs[num][j];
          bool fre = true;
          for (int jj = 0; jj < (gf[i].size()); jj++) {
            if (gs[gf[i][jj]].size() <= 1) fre = false;
          }
          if (fre) {
            if (volne.find(i) == volne.end()) volne.insert(i);
          }
        }
    }
    for (int j = 0; j < (gf[num].size()); j++) {
      if (gs[gf[num][j]].size() == 1) volne.erase(gs[gf[num][j]][0]);
    }
    volne.erase(itv);
  }
  long long kon = 1;
  long long out = 0;
  for (int i = (res.size() - 1); i >= (0); i--) {
    out += (long long)res[i] * kon;
    out %= mod;
    kon *= n;
    kon %= mod;
  }
  cout << out << endl;
  return 0;
}
