#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n;
long long ans;
set<int> s;
map<pair<int, int>, int> mp;
pair<int, int> pos[100005];
inline int cnt(int x, int y) {
  int res = 0;
  for (int i = -1; i <= 1; i++)
    if (mp[make_pair(x + i, y - 1)] != 0) res++;
  return res;
}
inline bool can_ins(int t) {
  int x = pos[t].first;
  int y = pos[t].second;
  for (int j = -1; j <= 1; j++)
    if (mp[make_pair(x + j, y + 1)] != 0 && cnt(x + j, y + 1) == 1)
      return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    mp[make_pair(x, y)] = i;
    pos[i] = make_pair(x, y);
  }
  for (int i = 1; i <= n; i++)
    if (can_ins(i)) s.insert(i);
  for (int ii = 1; ii <= n; ii++) {
    int t;
    if (ii % 2)
      t = *s.rbegin();
    else
      t = *s.begin();
    s.erase(t);
    int x = pos[t].first;
    int y = pos[t].second;
    mp[pos[t]] = 0;
    for (int j = -2; j <= 2; j++)
      for (int k = -1; k <= 0; k++) {
        int id = mp[make_pair(x + j, y + k)];
        if (id == 0) continue;
        s.erase(id);
        if (can_ins(id)) s.insert(id);
      }
    ans = ans * (long long)n + (long long)(t - 1);
    ans = ans % 1000000009;
  }
  cout << ans;
  return 0;
}
