#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 10;
const int mod = 1e9 + 9;
priority_queue<int> p, q;
int N;
int x[MAX_N], y[MAX_N];
int fr[MAX_N];
int res;
map<pair<int, int>, int> G;
int get_idx(int x, int y) {
  if (G.find({x, y}) != G.end()) return G[{x, y}];
  return -1;
}
int count_bot(int i) {
  int c = 0;
  for (int j = -1; j <= 1; j++)
    if (get_idx(x[i] + j, y[i] - 1) != -1) c++;
  return c;
}
int check_fr(int i) {
  for (int j = -1; j <= 1; j++) {
    int k = get_idx(x[i] + j, y[i] + 1);
    if (k != -1 && count_bot(k) == 1) return 0;
  }
  return 1;
}
void push(int i) {
  res = (1LL * res * N) % mod;
  res += i;
  res %= mod;
  G.erase(G.find({x[i], y[i]}));
  if (y[i] > 0) {
    for (int j = -1; j <= 1; j++) {
      int k = get_idx(x[i] + j, y[i] - 1);
      if (k != -1 && check_fr(k)) {
        fr[k] = 1;
        p.push(k);
        q.push(-k);
      }
    }
  }
  for (int j = -2; j <= 2; j++) {
    int k = get_idx(x[i] + j, y[i]);
    if (k == -1) continue;
    fr[k] &= check_fr(k);
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d%d", x + i, y + i);
    G[{x[i], y[i]}] = i;
  }
  for (int i = 0; i < N; i++) {
    fr[i] = check_fr(i);
    if (fr[i]) {
      p.push(i);
      q.push(-i);
    }
  }
  for (int i = 0; i < N; i++) {
    priority_queue<int>& pq = i % 2 == 0 ? p : q;
    while (1) {
      int t = abs(pq.top());
      pq.pop();
      if (fr[t] && get_idx(x[t], y[t]) != -1) {
        push(t);
        break;
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
