#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b,
                 long long mod = (long long)(1e9 + 7)) {
  if (!b) return 1;
  a %= mod;
  return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mxn = 1e5, mod = 1e9 + 9;
long long ans = 0;
int n;
int x[mxn], y[mxn];
int support[mxn];
bool inqueue[mxn];
map<int, map<int, int> > ds;
priority_queue<int, vector<int>, greater<int> > pq;
priority_queue<int, vector<int>, less<int> > pq2;
int take(int i, int j) {
  if (!ds.count(i) || !ds[i].count(j)) return -1;
  return ds[i][j];
}
void supportAdjust(int i) {
  if (i == -1) return;
  support[i] = 0;
  for (int d = -1; d <= 1; d++)
    if (take(x[i] + d, y[i] - 1) != -1) support[i]++;
  if (y[i] == 0) support[i] = 30000;
}
void evaluate(int i) {
  if (i == -1) return;
  bool b4 = inqueue[i];
  inqueue[i] = false;
  for (int d = -1; d <= 1; d++)
    if (take(x[i] + d, y[i] + 1) != -1)
      inqueue[i] |= support[take(x[i] + d, y[i] + 1)] == 1;
  inqueue[i] ^= 1;
  if (!b4 && inqueue[i]) {
    pq.push(i);
    pq2.push(i);
  }
}
void takeout(int turn) {
  int i;
  if (turn % 2 == 0) {
    while (pq2.size() && !inqueue[pq2.top()]) pq2.pop();
    if (!pq2.size()) return;
    i = pq2.top();
    pq2.pop();
  } else {
    while (pq.size() && !inqueue[pq.top()]) pq.pop();
    if (!pq.size()) return;
    i = pq.top();
    pq.pop();
  }
  ans = ((ans * n) % mod + i) % mod;
  inqueue[i] = 0;
  ds[x[i]].erase(y[i]);
  for (int d = -1; d <= 1; d++) supportAdjust(take(x[i] + d, y[i] + 1));
  for (int d = -2; d <= 2; d++) evaluate(take(x[i] + d, y[i]));
  for (int d = -1; d <= 1; d++) evaluate(take(x[i] + d, y[i] - 1));
}
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) inqueue[i] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x[i]);
    scanf("%d", &y[i]);
    if (!ds.count(x[i])) ds[x[i]] = map<int, int>();
    ds[x[i]][y[i]] = i;
  }
  for (int i = 0; i < n; i++) supportAdjust(i);
  for (int i = 0; i < n; i++) evaluate(i);
  for (int i = 0; i < n; i++) takeout(i);
  cout << ans % mod << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
