#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)(1e5) + 10;
const int MOD = (int)(1e9) + 9;
struct Point {
  Point() {}
  Point(int xx, int yy) : x(xx), y(yy) {}
  int x, y;
  bool operator<(const Point &a) const {
    if (a.y == y) return x < a.x;
    return y < a.y;
  }
} point[MAX_N];
int n;
map<Point, int> link;
set<int> cube_set;
bool available[MAX_N];
bool removed[MAX_N];
int get_support_num(Point a) {
  if (link.find(a) == link.end() || removed[link[a]]) return 0;
  int ret = 0;
  for (int i = a.x - 1; i <= a.x + 1; i++) {
    Point temp = Point(i, a.y - 1);
    if (link.find(temp) != link.end() && !removed[link[temp]]) {
      ret++;
    }
  }
  return ret;
}
bool get_availability(Point a) {
  for (int i = a.x - 1; i <= a.x + 1; i++) {
    if (get_support_num(Point(i, a.y + 1)) == 1) {
      return false;
    }
  }
  return true;
}
void release(Point a) {
  for (int i = a.x - 2; i <= a.x + 2; i++) {
    Point temp = Point(i, a.y);
    if (link.find(temp) == link.end() || removed[link[temp]]) continue;
    int index = link[temp];
    available[index] = get_availability(point[index]);
    if (available[index])
      cube_set.insert(index);
    else
      cube_set.erase(index);
  }
  for (int i = a.x - 1; i <= a.x + 1; i++) {
    Point temp = Point(i, a.y - 1);
    if (link.find(temp) == link.end() || removed[link[temp]]) continue;
    int index = link[temp];
    available[index] = get_availability(point[index]);
    if (available[index])
      cube_set.insert(index);
    else
      cube_set.erase(index);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    link[Point(x, y)] = i;
    point[i] = Point(x, y);
  }
  for (int i = 0; i < n; i++) {
    available[i] = get_availability(point[i]);
    if (available[i]) {
      cube_set.insert(i);
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int temp;
    if (i % 2 == 1)
      temp = *cube_set.begin();
    else {
      set<int>::iterator it = cube_set.end();
      it--;
      temp = *(it);
    }
    cube_set.erase(temp);
    removed[temp] = true;
    release(point[temp]);
    ans = (ans * n + temp) % MOD;
    ;
  }
  int out_ans = ans;
  printf("%d\n", out_ans);
  return 0;
}
