#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000009;
const int maxn = 100005;
typedef struct Point {
  int x, y;
  Point(int x = 0, int y = 0) : x(x), y(y) {}
  friend bool operator<(Point a, Point b) {
    return a.x != b.x ? a.x < b.x : a.y < b.y;
  }
} Point;
map<Point, int> mp;
map<Point, int>::iterator it;
int m, ret[maxn], up[maxn], down[maxn];
Point p[maxn];
set<int> S;
set<int>::iterator it2;
bool v[maxn];
void input() {
  cin >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
    mp[p[i]] = i;
  }
  for (int i = 0; i < m; i++) {
    for (int j = -1; j <= 1; j++) {
      if (mp.find(Point(p[i].x + j, p[i].y + 1)) != mp.end()) up[i]++;
      if (mp.find(Point(p[i].x + j, p[i].y - 1)) != mp.end()) down[i]++;
    }
  }
  for (int i = 0; i < m; i++) {
    bool ok = 1;
    for (int j = -1; j <= 1; j++) {
      it = mp.find(Point(p[i].x + j, p[i].y + 1));
      if (it != mp.end() && down[(*it).second] == 1) ok = 0;
    }
    if (ok) S.insert(i);
  }
}
int main() {
  input();
  long long ret = 0;
  int u, ca = 0;
  while (!S.empty()) {
    if (ca % 2 == 0) {
      it2 = S.end();
      it2--;
    } else
      it2 = S.begin();
    u = (*it2);
    S.erase(u);
    mp.erase(p[u]);
    v[u] = 1;
    ret = (ret * m + u) % mod;
    for (int j = -1; j <= 1; j++) {
      it = mp.find(Point(p[u].x + j, p[u].y + 1));
      if (it == mp.end()) continue;
      down[(*it).second]--;
      if (down[(*it).second] == 1) {
        int vv = (*it).second;
        for (int k = -1; k <= 1; k++) {
          it = mp.find(Point(p[vv].x + k, p[vv].y - 1));
          if (it == mp.end()) continue;
          if (!v[(*it).second] && S.find((*it).second) != S.end())
            S.erase((*it).second);
        }
      }
    }
    for (int j = -1; j <= 1; j++) {
      it = mp.find(Point(p[u].x + j, p[u].y - 1));
      if (it == mp.end()) continue;
      int vv = (*it).second;
      up[vv]--;
      bool ok = 1;
      for (int k = -1; k <= 1; k++) {
        it = mp.find(Point(p[vv].x + k, p[vv].y + 1));
        if (it != mp.end() && down[(*it).second] == 1) ok = 0;
      }
      if (ok) S.insert(vv);
    }
    ca++;
  }
  printf("%I64d\n", ret);
  return 0;
}
