#include <bits/stdc++.h>
using namespace std;
int n, a[1000005], b[1000005];
int xx[] = {-2, -1, 1, 2, -1, 0, 1};
int yy[] = {0, 0, 0, 0, -1, -1, -1};
long long ans = 0;
map<pair<int, int>, int> h;
set<int> s;
vector<int> cvp;
int ne(int x, int y) {
  if (h.count(make_pair(x, y))) return h[make_pair(x, y)];
  return 0;
}
bool bak(int x, int y) {
  if (!ne(x, y)) return 0;
  int u1 = ne(x - 1, y + 1);
  int u2 = ne(x, y + 1);
  int u3 = ne(x + 1, y + 1);
  if (u1 and !ne(x - 1, y) and !ne(x - 2, y)) return 0;
  if (u2 and !ne(x - 1, y) and !ne(x + 1, y)) return 0;
  if (u3 and !ne(x + 1, y) and !ne(x + 2, y)) return 0;
  return 1;
}
void cikar(int i) {
  h[make_pair(a[i], b[i])] = 0;
  s.erase(i);
  cvp.push_back(i - 1);
  for (int j = 0; j < 7; j++)
    if (bak(a[i] + xx[j], b[i] + yy[j]))
      s.insert(ne(a[i] + xx[j], b[i] + yy[j]));
    else
      s.erase(ne(a[i] + xx[j], b[i] + yy[j]));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", a + i, b + i);
    h[make_pair(a[i], b[i])] = i;
  }
  for (int i = 1; i <= n; i++)
    if (bak(a[i], b[i])) s.insert(i);
  while (!s.empty()) {
    cikar(*s.rbegin());
    if (!s.empty()) cikar(*s.begin());
  }
  for (int i = 0; i < cvp.size(); i++) ans = (ans * n + cvp[i]) % 1000000009;
  printf("%lld\n", ans);
  return 0;
}
