#include <bits/stdc++.h>
const double eps = 1e-10;
using namespace std;
int zzz = 0;
const int NN = 100022;
vector<pair<long long, long long>> cr;
map<pair<int, int>, int> mp;
int N, M, L;
long long answ;
set<int> st;
bool isOn(int x, int y) { return mp.count({x, y}) && mp[{x, y}] != -1; }
bool check(int x, int y) {
  if (!isOn(x, y)) return 1;
  if (y == 0) return 1;
  if (!isOn(x - 1, y - 1) && !isOn(x, y - 1) && !isOn(x + 1, y - 1)) {
    return 0;
  }
  return 1;
}
bool good(int p) {
  int cx = cr[p].first, cy = cr[p].second;
  mp[{cx, cy}] = -1;
  if (!check(cx - 1, cy + 1) || !check(cx, cy + 1) || !check(cx + 1, cy + 1)) {
    mp[{cx, cy}] = p;
    return 0;
  }
  mp[{cx, cy}] = p;
  return 1;
}
void refresh(int x, int y) {
  if (!isOn(x, y)) return;
  int p = mp[{x, y}];
  if (st.count(p)) st.erase(p);
  if (good(p)) st.insert(p);
}
void removeIt(int p) {
  answ = (answ * N + p) % 1000000009;
  mp[{cr[p].first, cr[p].second}] = -1;
  st.erase(p);
  int a = cr[p].first, b = cr[p].second;
  refresh(a - 2, b);
  refresh(a - 1, b);
  refresh(a + 1, b);
  refresh(a + 2, b);
  refresh(a - 1, b - 1);
  refresh(a, b - 1);
  refresh(a + 1, b - 1);
}
int main() {
  scanf("%d", &N);
  cr.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &cr[i].first, &cr[i].second);
    mp[{cr[i].first, cr[i].second}] = i;
  }
  for (size_t i = 0; i < N; i++) {
    if (good(i)) st.insert(i);
  }
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      removeIt(*(st.rbegin()));
    } else {
      removeIt(*(st.begin()));
    }
  }
  printf("%I64d\n", answ);
  return 0;
  system("pause");
}
