#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
const int MOD = (int)1e9 + 9;
int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int mul(int a, int b) {
  long long c = (long long)a * b;
  return (int)(c % MOD);
}
int n;
pair<int, int> cube[N];
map<pair<int, int>, int> cube_to_ind;
set<int> candidates;
int res[N];
pair<int, int> add(pair<int, int> c, int dx, int dy) {
  return make_pair(c.first + dx, c.second + dy);
}
int has(pair<int, int> c) { return cube_to_ind.count(c); }
bool is_stable(pair<int, int> c) {
  if (has(c) == 0) return true;
  if (c.second == 0) return true;
  int cnt = has(add(c, -1, -1)) + has(add(c, 0, -1)) + has(add(c, 1, -1));
  return cnt > 1;
}
void try_take(pair<int, int> c) {
  auto it = cube_to_ind.find(c);
  if (it == cube_to_ind.end()) return;
  int ind = it->second;
  if (is_stable(add(c, -1, 1)) && is_stable(add(c, 0, 1)) &&
      is_stable(add(c, 1, 1))) {
    candidates.insert(ind);
  } else {
    candidates.erase(ind);
  }
}
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", &cube[i].first, &cube[i].second);
  for (int i = 0; i < n; i++) cube_to_ind[cube[i]] = i;
  for (int i = 0; i < n; i++) try_take(cube[i]);
  for (int i = 0; !candidates.empty(); i++) {
    int ind;
    if (i % 2 == 0) {
      ind = *prev(candidates.end());
      candidates.erase(prev(candidates.end()));
    } else {
      ind = *candidates.begin();
      candidates.erase(candidates.begin());
    }
    res[i] = ind;
    auto c = cube[ind];
    cube_to_ind.erase(c);
    try_take(add(c, -1, -1));
    try_take(add(c, 0, -1));
    try_take(add(c, 1, -1));
    try_take(add(c, -1, 0));
    try_take(add(c, 1, 0));
    try_take(add(c, -2, 0));
    try_take(add(c, 2, 0));
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = add(mul(ans, n), res[i]);
  printf("%d\n", ans);
}
int main() {
  solve();
  0;
  return 0;
}
