#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
map<pair<int, int>, int> mp;
int x[100010];
int y[100010];
long long ans[100010];
bool unable[100010];
bool judge(int xx, int yy) {
  int ok = 1;
  if (mp.count(make_pair(xx, yy + 1))) {
    if (mp.count(make_pair(xx - 1, yy)) == 0 &&
        mp.count(make_pair(xx + 1, yy)) == 0)
      return 0;
  }
  if (mp.count(make_pair(xx + 1, yy + 1))) {
    if (mp.count(make_pair(xx + 1, yy)) == 0 &&
        mp.count(make_pair(xx + 2, yy)) == 0)
      return 0;
  }
  if (mp.count(make_pair(xx - 1, yy + 1))) {
    if (mp.count(make_pair(xx - 2, yy)) == 0 &&
        mp.count(make_pair(xx - 1, yy)) == 0)
      return 0;
  }
  return ok;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    mp[make_pair(x[i], y[i])] = i;
  }
  priority_queue<int> MAX;
  priority_queue<int, vector<int>, greater<int> > MIN;
  for (int i = 1; i <= n; i++) {
    if (judge(x[i], y[i])) {
      MAX.push(mp[make_pair(x[i], y[i])]);
      MIN.push(mp[make_pair(x[i], y[i])]);
    }
  }
  for (int i = 1; i <= n; i++) {
    int xx, yy;
    if (i & 1) {
      ans[i] = MAX.top();
      MAX.pop();
    } else {
      ans[i] = MIN.top();
      MIN.pop();
    }
    if (unable[ans[i]]) {
      i--;
      continue;
    }
    if (!judge(x[ans[i]], y[ans[i]])) {
      i--;
      continue;
    }
    unable[ans[i]] = 1;
    xx = x[ans[i]];
    yy = y[ans[i]];
    mp.erase(make_pair(xx, yy));
    if (mp.count(make_pair(xx - 1, yy - 1))) {
      if (judge(xx - 1, yy - 1)) {
        MAX.push(mp[make_pair(xx - 1, yy - 1)]);
        MIN.push(mp[make_pair(xx - 1, yy - 1)]);
      }
    }
    if (mp.count(make_pair(xx, yy - 1))) {
      if (judge(xx, yy - 1)) {
        MAX.push(mp[make_pair(xx, yy - 1)]);
        MIN.push(mp[make_pair(xx, yy - 1)]);
      }
    }
    if (mp.count(make_pair(xx + 1, yy - 1))) {
      if (judge(xx + 1, yy - 1)) {
        MAX.push(mp[make_pair(xx + 1, yy - 1)]);
        MIN.push(mp[make_pair(xx + 1, yy - 1)]);
      }
    }
  }
  long long tmp = 1;
  long long re = 0;
  for (int i = n; i >= 1; i--) {
    re += (ans[i] - 1) * tmp;
    re %= mod;
    tmp *= n;
    tmp %= mod;
  }
  cout << re << endl;
  return 0;
}
