#include <bits/stdc++.h>
using namespace std;
const int INF = (-1u) / 2;
const long long int INF2 = (-1ull) / 2;
int a, b, i, c[101100], j, k, n, m, timer = 0, l, r, x, y;
int t[511000], cnt = 0, fl = 0, a2, a3 = -1000000, ans = 0;
pair<int, int> p[100020];
map<pair<int, int>, int> mp;
set<int> st;
set<int>::iterator it;
long long int res, pw;
int nbchild(int x, int y) {
  int res = 0;
  if (mp[{x, y - 1}] != 0) res++;
  if (mp[{x + 1, y - 1}] != 0) res++;
  if (mp[{x - 1, y - 1}] != 0) res++;
  return res;
}
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    p[i] = make_pair(x, y);
    mp[{x, y}] = i + 1;
  }
  for (i = 0; i < n; i++) {
    x = p[i].first;
    y = p[i].second;
    fl = 1;
    for (j = -1; j <= 1; j++) {
      if (mp[{x + j, y + 1}] != 0 && nbchild(x + j, y + 1) == 1) {
        fl = 0;
        break;
      }
    }
    if (fl == 1) {
      st.insert(i);
    }
  }
  for (i = 0; i < n; i++) {
    if (i % 2 == 0) {
      it = st.end();
      it--;
      c[i] = *it;
      x = p[(*it)].first;
      y = p[(*it)].second;
      st.erase(it);
    } else {
      it = st.begin();
      c[i] = *it;
      x = p[(*it)].first;
      y = p[(*it)].second;
      st.erase(it);
    }
    a = x;
    b = y;
    mp[{x, y}] = 0;
    for (k = -2; k <= 2; k++) {
      if (k == 0) continue;
      x = a + k;
      fl = 1;
      if (mp[{x, y}] == 0) continue;
      for (j = -1; j <= 1; j++) {
        if (mp[{x + j, y + 1}] != 0 && nbchild(x + j, y + 1) == 1) {
          fl = 0;
          break;
        }
      }
      if (fl == 0 && st.find(mp[{x, y}] - 1) != st.end()) {
        st.erase(mp[{x, y}] - 1);
      }
    }
    for (k = -1; k <= 1; k++) {
      x = a + k;
      fl = 1;
      if (mp[{x, y - 1}] == 0) continue;
      for (j = -1; j <= 1; j++) {
        if (mp[{x + j, y}] != 0 && nbchild(x + j, y) == 1) {
          fl = 0;
          break;
        }
      }
      if (fl == 1) st.insert(mp[{x, y - 1}] - 1);
    }
  }
  pw = 1;
  for (i = n - 1; i >= 0; i--) {
    res += (pw * c[i]);
    pw *= (n * 1ll);
    pw %= (1000000009ll);
    res %= (1000000009ll);
  }
  cout << res << endl;
  return 0;
}
