#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000009;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 101000;
map<pair<int, int>, int> hs;
set<int> st;
int n, x[N], y[N];
long long ans;
bool exist(int x, int y) {
  return hs.count(make_pair(x, y)) && hs[make_pair(x, y)] != -1;
}
bool check(int x, int y) {
  if (!exist(x, y)) return 1;
  if (y == 0) return 1;
  if (!exist(x - 1, y - 1) && !exist(x, y - 1) && !exist(x + 1, y - 1))
    return 0;
  return 1;
}
bool valid(int p) {
  int cx = x[p], cy = y[p];
  hs[make_pair(cx, cy)] = -1;
  if (!check(cx - 1, cy + 1) || !check(cx, cy + 1) || !check(cx + 1, cy + 1)) {
    hs[make_pair(cx, cy)] = p;
    return 0;
  }
  hs[make_pair(cx, cy)] = p;
  return 1;
}
void refresh(int x, int y) {
  if (!exist(x, y)) return;
  int p = hs[make_pair(x, y)];
  if (st.count(p)) st.erase(p);
  if (valid(p)) st.insert(p);
}
void del(int p) {
  ans = (ans * n + p) % mod;
  hs[make_pair(x[p], y[p])] = -1;
  st.erase(p);
  refresh(x[p] - 2, y[p]);
  refresh(x[p] - 1, y[p]);
  refresh(x[p] + 1, y[p]);
  refresh(x[p] + 2, y[p]);
  refresh(x[p] - 1, y[p] - 1);
  refresh(x[p], y[p] - 1);
  refresh(x[p] + 1, y[p] - 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d", x + i, y + i), hs[make_pair(x[i], y[i])] = i;
  for (int i = 0; i < n; i++)
    if (valid(i)) st.insert(i);
  for (int i = 0; i < n; i++) {
    assert(!st.empty());
    if (i % 2 == 0)
      del(*(--st.end()));
    else
      del(*st.begin());
  }
  printf("%I64d\n", ans);
}
