#include <bits/stdc++.h>
using namespace std;
int x[102400], y[102400];
map<pair<int, int>, int> id;
bool no[102400];
set<int> u[102400], v[102400];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, y + i);
    id[{x[i], y[i]}] = i;
  }
  for (int i = 0; i < n; ++i)
    for (int X : {x[i] - 1, x[i], x[i] + 1}) {
      auto it = id.find({X, y[i] - 1});
      if (it != id.end()) {
        u[i].insert(it->second);
        v[it->second].insert(i);
      }
    }
  set<int> ok;
  for (int i = 0; i < n; ++i)
    if (u[i].size() == 1) no[*u[i].begin()] = true;
  for (int i = 0; i < n; ++i)
    if (!no[i]) ok.insert(i);
  long long ans = 0;
  for (int i = 0, z; i < n; ++i) {
    int j = (i & 1) ? *ok.begin() : *ok.rbegin();
    ok.erase(j);
    ans = (ans * n + j) % 1000000009;
    for (int x : v[j]) {
      u[x].erase(j);
      if (u[x].size() == 1 && !no[z = *u[x].begin()]) {
        no[z] = true;
        ok.erase(z);
      }
    }
    for (int y : u[j]) {
      v[y].erase(j);
      ok.insert(y);
      no[y] = false;
      for (int t : v[y])
        if (u[t].size() == 1) {
          no[y] = true;
          ok.erase(y);
          break;
        }
    }
  }
  printf("%d\n", (int)ans);
}
