#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long MOD = 1e9 + 9;
long long res;
set<int> se;
map<pair<int, int>, int> ma;
int y[MAXN], x[MAXN];
int m;
long long _pow(long long a, long long b) {
  if (b == 0) return 1;
  long long res = _pow(a, b / 2);
  res = res * res % MOD;
  if (b & 1) res = res * a % MOD;
  return res;
}
int cntBelow(int u, int v) {
  int res = 0;
  if (ma.find(pair<int, int>(u - 1, v - 1)) != ma.end()) res++;
  if (ma.find(pair<int, int>(u, v - 1)) != ma.end()) res++;
  if (ma.find(pair<int, int>(u + 1, v - 1)) != ma.end()) res++;
  return res;
}
bool canTake(int u, int v) {
  return (ma.find(pair<int, int>(u - 1, v + 1)) == ma.end() ||
          cntBelow(u - 1, v + 1) > 1) &&
         (ma.find(pair<int, int>(u, v + 1)) == ma.end() ||
          cntBelow(u, v + 1) > 1) &&
         (ma.find(pair<int, int>(u + 1, v + 1)) == ma.end() ||
          cntBelow(u + 1, v + 1) > 1);
}
void checkCanTake(int u, int v) {
  if (ma.find(pair<int, int>(u, v)) == ma.end()) return;
  if (canTake(u, v)) se.insert(ma[pair<int, int>(u, v)]);
}
void checkTake(int u, int v) {
  if (ma.find(pair<int, int>(u, v)) == ma.end()) return;
  int cnt = cntBelow(u, v);
  if (cnt == 1) {
    map<pair<int, int>, int>::iterator it =
        ma.find(pair<int, int>(u - 1, v - 1));
    if (it != ma.end()) {
      if (se.find(it->second) != se.end()) {
        se.erase(se.find(it->second));
        return;
      }
    }
    it = ma.find(pair<int, int>(u, v - 1));
    if (it != ma.end()) {
      if (se.find(it->second) != se.end()) {
        se.erase(se.find(it->second));
        return;
      }
    }
    it = ma.find(pair<int, int>(u + 1, v - 1));
    if (it != ma.end()) {
      if (se.find(it->second) != se.end()) {
        se.erase(se.find(it->second));
        return;
      }
    }
  }
}
void take(int u, int v) {
  checkTake(u - 1, v + 1);
  checkTake(u, v + 1);
  checkTake(u + 1, v + 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    ma[pair<int, int>(x[i], y[i])] = i;
  }
  for (int i = 0; i < m; i++)
    if (canTake(x[i], y[i])) se.insert(i);
  for (int i = m - 1; i >= 0; i--) {
    int u;
    if ((m - i) & 1)
      u = *se.rbegin();
    else
      u = *se.begin();
    se.erase(u);
    ma.erase(pair<int, int>(x[u], y[u]));
    take(x[u], y[u]);
    res = (res + _pow(m, i) * (long long)u % MOD) % MOD;
    checkCanTake(x[u] - 1, y[u] - 1);
    checkCanTake(x[u], y[u] - 1);
    checkCanTake(x[u] + 1, y[u] - 1);
  }
  cout << res << '\n';
  return 0;
}
