#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 9;
map<pair<int, int>, int> mp;
map<pair<int, int>, int>::iterator it;
int x[maxn], y[maxn];
set<int> s;
bool down(int x, int y, int xx, int yy) {
  for (int i = -1; i <= 1; i++) {
    if (xx == x + i && yy == y - 1) continue;
    if (mp.count(make_pair(x + i, y - 1))) return true;
  }
  return false;
}
bool judge(int x, int y) {
  for (int i = -1; i <= 1; i++)
    if (mp.count(make_pair(x + i, y + 1)))
      if (!down(x + i, y + 1, x, y)) return false;
  return true;
}
int main() {
  int m;
  long long ans = 0;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    mp[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < m; i++)
    if (judge(x[i], y[i])) s.insert(i);
  for (int i = 0; i < m; i++) {
    int id = i & 1 ? *s.begin() : *s.rbegin();
    s.erase(id);
    ans = (ans * m + id) % mod;
    mp.erase(make_pair(x[id], y[id]));
    for (int j = -2; j <= 2; j++) {
      int nx = x[id] + j, ny = y[id];
      if ((it = mp.find(make_pair(nx, ny))) != mp.end() && !judge(nx, ny))
        s.erase(it->second);
    }
    for (int j = -1; j <= 1; j++) {
      int nx = x[id] + j, ny = y[id] - 1;
      if ((it = mp.find(make_pair(nx, ny))) != mp.end() && judge(nx, ny))
        s.insert(it->second);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
