#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e5 + 7;
const int MOD = (int)1e9 + 9;
const int dx[] = {-1, 0, 1};
int n;
int sx[MAXN], sy[MAXN];
bool u[MAXN];
set<int> can;
map<pair<int, int>, int> pos;
bool onlyOne(int x, int y) {
  if (!pos.count(make_pair(x, y))) return false;
  int cid = pos[make_pair(x, y)];
  if (u[cid]) return false;
  int delid, nx, ny, id;
  int cnt = 0;
  for (int d = 0; d < 3; d++) {
    nx = x + dx[d];
    ny = y - 1;
    if (!pos.count(make_pair(nx, ny))) continue;
    id = pos[make_pair(nx, ny)];
    if (!u[id]) {
      cnt++;
      delid = id;
    }
  }
  return (cnt == 1);
}
bool check(int x, int y) {
  if (!pos.count(make_pair(x, y))) return false;
  for (int d = 0; d < 3; d++) {
    int nx = x + dx[d];
    int ny = y + 1;
    if (onlyOne(nx, ny)) return false;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &sx[i], &sy[i]);
    pos[make_pair(sx[i], sy[i])] = i;
  }
  for (int i = 0; i < n; i++) {
    if (check(sx[i], sy[i])) can.insert(i);
  }
  vector<int> ans;
  int turn = 0;
  while (!can.empty()) {
    set<int>::iterator cur;
    if (!turn)
      cur = can.end(), --cur;
    else
      cur = can.begin();
    int v = *cur;
    ans.push_back(v);
    can.erase(cur);
    u[v] = true;
    for (int x = sx[v] - 2; x <= sx[v] + 2; x++) {
      for (int y = sy[v] - 1; y <= sy[v] + 1; y++) {
        if (pos.count(make_pair(x, y))) {
          int id = pos[make_pair(x, y)];
          can.erase(id);
          if (!u[id]) {
            if (check(x, y)) can.insert(id);
          }
        }
      }
    }
    turn ^= 1;
  }
  reverse(ans.begin(), ans.end());
  int res = 0, p = 1;
  for (int i = 0; i < ans.size(); i++) {
    res += (1LL * ans[i] * p) % MOD;
    p = (1LL * p * n) % MOD;
    res %= MOD;
  }
  cout << res;
  return 0;
}
