#include <bits/stdc++.h>
using namespace std;
set<int> s;
set<int>::iterator it;
int n;
long long ans = 0;
map<pair<int, int>, int> mp;
int x_[100010];
int y_[100010];
int b[100010];
void change(int x, int y) {
  if (b[mp[make_pair(x - 1, y + 1)]] == 1) {
    s.erase(mp[make_pair(x, y)]);
    return;
  }
  if (b[mp[make_pair(x, y + 1)]] == 1) {
    s.erase(mp[make_pair(x, y)]);
    return;
  }
  if (b[mp[make_pair(x + 1, y + 1)]] == 1) {
    s.erase(mp[make_pair(x, y)]);
    return;
  }
  s.insert(mp[make_pair(x, y)]);
  return;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    mp[make_pair(x, y)] = i;
    x_[i] = x;
    y_[i] = y;
  }
  for (int i = 1; i <= n; i++) {
    int x, y;
    x = x_[i];
    y = y_[i];
    int f;
    f = mp[make_pair(x, y)];
    if (y == 0) continue;
    int t;
    t = mp[make_pair(x - 1, y - 1)];
    if (t) b[f]++;
    t = mp[make_pair(x, y - 1)];
    if (t) b[f]++;
    t = mp[make_pair(x + 1, y - 1)];
    if (t) b[f]++;
  }
  for (int i = 1; i <= n; i++) {
    int x, y;
    x = x_[i];
    y = y_[i];
    change(x, y);
  }
  bool flag = 0;
  while (!s.empty()) {
    int f;
    if (!flag) {
      it = s.end();
      it--;
      f = *it;
    } else {
      it = s.begin();
      f = *it;
    }
    s.erase(f);
    ans = (ans * n + f - 1) % 1000000009;
    flag = !flag;
    mp[make_pair(x_[f], y_[f])] = 0;
    int x, y;
    x = x_[f];
    y = y_[f];
    int t;
    t = mp[make_pair(x - 1, y + 1)];
    if (t) b[t]--;
    t = mp[make_pair(x, y + 1)];
    if (t) b[t]--;
    t = mp[make_pair(x + 1, y + 1)];
    if (t) b[t]--;
    t = mp[make_pair(x - 1, y - 1)];
    if (t) change(x - 1, y - 1);
    t = mp[make_pair(x, y - 1)];
    if (t) change(x, y - 1);
    t = mp[make_pair(x + 1, y - 1)];
    if (t) change(x + 1, y - 1);
    t = mp[make_pair(x - 1, y)];
    if (t) change(x - 1, y);
    t = mp[make_pair(x - 2, y)];
    if (t) change(x - 2, y);
    t = mp[make_pair(x + 1, y)];
    if (t) change(x + 1, y);
    t = mp[make_pair(x + 2, y)];
    if (t) change(x + 2, y);
  }
  cout << ans;
}
