#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 9;
const int maxn = 100100;
struct BOX {
  int x, y, id;
} box[maxn];
int n;
map<pair<int, int>, int> mPI;
set<pair<int, int> > Pt;
set<int> St;
bool isST(int id) {
  int x = box[id].x;
  int y = box[id].y;
  pair<int, int> tp;
  tp = make_pair(x - 1, y + 1);
  if (Pt.count(tp) == 1) {
    if (Pt.count(make_pair(x - 2, y)) || Pt.count(make_pair(x - 1, y)))
      ;
    else
      return false;
  }
  tp = make_pair(x, y + 1);
  if (Pt.count(tp) == 1) {
    if (Pt.count(make_pair(x - 1, y)) || Pt.count(make_pair(x + 1, y)))
      ;
    else
      return false;
  }
  tp = make_pair(x + 1, y + 1);
  if (Pt.count(tp) == 1) {
    if (Pt.count(make_pair(x + 1, y)) || Pt.count(make_pair(x + 2, y)))
      ;
    else
      return false;
  }
  return true;
}
void checkST(int id) {
  if (isST(id)) {
    St.insert(id);
  } else {
    if (St.count(id)) St.erase(id);
  }
}
void checkround(int id) {
  int x = box[id].x;
  int y = box[id].y;
  checkST(id);
  for (int i = -1; i <= 1; i++) {
    for (int j = -1; j <= 1; j += 2) {
      int nx = x + i, ny = y + j;
      pair<int, int> tp = make_pair(nx, ny);
      if (Pt.count(tp) == 1) {
        int dd = mPI[tp];
        checkST(dd);
      }
    }
  }
}
void Remove(int id) {
  int x = box[id].x;
  int y = box[id].y;
  Pt.erase(make_pair(x, y));
  St.erase(id);
  for (int i = -1; i <= 1; i++) {
    for (int j = -1; j <= 1; j += 2) {
      int nx = x + i, ny = y + j;
      pair<int, int> tp = make_pair(nx, ny);
      if (Pt.count(tp) == 1) {
        int ID = mPI[tp];
        checkround(ID);
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    box[i] = (BOX){x, y, i};
    mPI[make_pair(x, y)] = i;
    Pt.insert(make_pair(x, y));
  }
  int mxid = 0, miid = 0;
  for (int i = 0; i < n; i++) {
    if (isST(i)) {
      St.insert(i);
      mxid = max(mxid, i);
      miid = min(miid, i);
    }
  }
  vector<int> vi;
  for (int loop = 0; loop < n; loop++) {
    if (loop % 2 == 0) {
      vi.push_back(mxid);
      Remove(mxid);
    } else {
      vi.push_back(miid);
      Remove(miid);
    }
    if (loop == n - 1) continue;
    miid = *St.begin();
    mxid = *(--St.end());
  }
  long long int ans = 0, base = 1;
  for (int sz = vi.size(), i = sz - 1; i >= 0; i--) {
    ans = (ans + base * vi[i] % mod) % mod;
    base = (base * n) % mod;
  }
  cout << ans % mod << endl;
  return 0;
}
