#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int dx[3] = {-1, 0, 1};
const int dy[3] = {-1, -1, -1};
const int INF = 1e9 + 9;
int n;
int x[maxn], y[maxn], cnt[maxn];
map<pair<int, int>, int> id;
set<int> s;
inline void upd(int i, int d) {
  if (!cnt[i]) s.erase(i);
  cnt[i] += d;
  if (!cnt[i]) s.insert(i);
  return;
}
inline void calc(int cx, int cy, int d) {
  if (id.find(make_pair(cx, cy)) == id.end()) return;
  int j = -1;
  for (int k = (0); k < (3); ++k) {
    int nx = cx + dx[k], ny = cy + dy[k];
    if (id.find(make_pair(nx, ny)) == id.end()) continue;
    if (!~j)
      j = id[make_pair(nx, ny)];
    else
      return;
  }
  if (~j) upd(j, d);
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i)
    scanf("%d%d", x + i, y + i), id[make_pair(x[i], y[i])] = i;
  for (int i = (0); i < (n); ++i) s.insert(i);
  for (int i = (0); i < (n); ++i) calc(x[i], y[i], 1);
  int ans = 0;
  for (int i = (0); i < (n); ++i) {
    set<int>::iterator it;
    if (i & 1)
      it = s.begin();
    else
      it = s.end(), --it;
    int p = *it;
    for (int k = (0); k < (3); ++k) {
      int nx = x[p] + dx[k], ny = y[p] - dy[k];
      calc(nx, ny, -1);
    }
    calc(x[p], y[p], -1);
    s.erase(it);
    id.erase(make_pair(x[p], y[p]));
    for (int k = (0); k < (3); ++k) {
      int nx = x[p] + dx[k], ny = y[p] - dy[k];
      calc(nx, ny, 1);
    }
    ans = (1ll * ans * n % INF + p) % INF;
  }
  printf("%d\n", ans);
  return 0;
}
