#include <bits/stdc++.h>
using namespace std;
int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}
const int N = 100000 + 10;
const int mod = 1e9 + 9;
int n, x[N], y[N], del[N], can[N];
map<pair<int, int>, int> M;
priority_queue<int> Y;
priority_queue<int, vector<int>, greater<int>> U;
vector<int> u[N], d[N];
bool check(int x) {
  for (int i : u[x])
    if (d[i].size() == 1) return 0;
  return 1;
}
void Kou(int x) {
  for (int v : u[x]) {
    if (del[v]) continue;
    d[v].erase(find(d[v].begin(), d[v].end(), x));
    if (d[v].size() == 1) can[d[v][0]] = 0;
  }
  for (int v : d[x]) {
    if (del[v]) continue;
    u[v].erase(find(u[v].begin(), u[v].end(), x));
    if (check(v)) can[v] = 1, Y.push(v), U.push(v);
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i)
    x[i] = read(), y[i] = read(), M[make_pair(x[i], y[i])] = i;
  for (int i = 1; i <= n; ++i) {
    if (M.count(make_pair(x[i] - 1, y[i] - 1))) {
      int j = M[make_pair(x[i] - 1, y[i] - 1)];
      d[i].emplace_back(j), u[j].emplace_back(i);
    }
    if (M.count(make_pair(x[i], y[i] - 1))) {
      int j = M[make_pair(x[i], y[i] - 1)];
      d[i].emplace_back(j), u[j].emplace_back(i);
    }
    if (M.count(make_pair(x[i] + 1, y[i] - 1))) {
      int j = M[make_pair(x[i] + 1, y[i] - 1)];
      d[i].emplace_back(j), u[j].emplace_back(i);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (check(i)) can[i] = 1, Y.push(i), U.push(i);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i & 1) {
      while (!Y.empty()) {
        int u = Y.top();
        Y.pop();
        if (del[u] || !can[u]) continue;
        del[u] = 1, ans = (1ll * ans * n + u - 1) % mod;
        Kou(u);
        break;
      }
    } else {
      while (!U.empty()) {
        int u = U.top();
        U.pop();
        if (del[u] || !can[u]) continue;
        del[u] = 1, ans = (1ll * ans * n + u - 1) % mod;
        Kou(u);
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
