#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const int MOD = 1e9 + 9;
const int N = 1e5 + 10;
int n, h[N] = {0}, g[N] = {0}, und[N] = {0};
pair<int, int> a[N];
vector<int> b[N], c[N];
map<pair<int, int>, int> ma;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    ma[a[i]] = i;
  }
  for (int i = 1; i <= n; i++)
    for (int j = -1; j <= 1; j++) {
      int idx = ma[pair<int, int>(a[i].first + j, a[i].second - 1)];
      if (idx) {
        und[i - 1]++;
        b[i - 1].push_back(idx - 1);
        c[idx - 1].push_back(i - 1);
      }
    }
  priority_queue<int> q[2];
  for (int i = 0; i < n; i++) {
    bool ok = true;
    for (auto x : c[i])
      if (und[x] == 1) ok = false;
    if (ok) q[0].push(i), q[1].push(-i);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int cur = i % 2;
    while (1) {
      int x = abs(q[cur].top());
      q[cur].pop();
      if (g[x]) continue;
      bool ok = true;
      for (auto y : c[x])
        if (!g[y] && und[y] == 1) ok = false;
      if (!ok) continue;
      g[x] = 1;
      und[x] = 0;
      ans = (ans * n + x) % MOD;
      for (auto y : b[x])
        if (!g[y]) {
          bool ok = true;
          for (auto z : c[y])
            if (!g[z] && und[z] == 1) ok = false;
          if (ok) q[0].push(y), q[1].push(-y);
        }
      for (auto y : c[x])
        if (!g[y]) und[y]--;
      break;
    }
  }
  cout << ans;
}
