#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const int mod = 1000000009;
const int inf = 0x3f3f3f3f;
map<pair<int, int>, int> ms;
bool vis[maxn];
int sumd(int x, int y) {
  if (y == 0) return inf;
  int s = 0;
  for (int i = x - 1; i <= x + 1; i++) {
    pair<int, int> tmp = make_pair(i, y - 1);
    if (ms.count(tmp)) {
      if (vis[ms[tmp]])
        continue;
      else
        s++;
    }
  }
  return s;
}
int sumu(int x, int y) {
  int s = 0;
  for (int i = x - 1; i <= x + 1; i++) {
    pair<int, int> tmp = make_pair(i, y + 1);
    if (ms.count(tmp)) {
      if (vis[ms[tmp]])
        continue;
      else
        s++;
    }
  }
  return s;
}
bool check(int x, int y) {
  if (!ms.count(make_pair(x, y))) return false;
  for (int i = x - 1; i <= x + 1; i++) {
    pair<int, int> tmp = make_pair(i, y + 1);
    if (!ms.count(tmp)) continue;
    if (sumd(i, y + 1) == 1) return false;
  }
  return true;
}
int x[maxn], y[maxn];
set<int> table;
vector<int> ans;
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    ms[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < m; i++)
    if (check(x[i], y[i])) table.insert(i);
  bool flag = false;
  while (!table.empty()) {
    int id;
    if (!flag)
      id = *table.rbegin();
    else
      id = *table.begin();
    int tx = x[id], ty = y[id];
    if (!check(tx, ty)) {
      table.erase(id);
      continue;
    }
    ans.push_back(id);
    ms.erase(make_pair(tx, ty));
    table.erase(id);
    for (int i = tx - 1; i <= tx + 1; i++)
      if (check(i, ty - 1)) table.insert(ms[make_pair(i, ty - 1)]);
    flag = !flag;
  }
  long long print_ans = 0;
  for (int i = 0; i < ans.size(); i++) {
    print_ans = (print_ans * m + ans[i]) % mod;
  }
  printf("%I64d\n", print_ans);
  return 0;
}
