#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005, mod = 1e9 + 9;
struct cube {
  int x, y, id;
  bool operator<(const cube &a) const {
    if (x == a.x) return y < a.y;
    return x < a.x;
  }
} p[MAX];
int n, perm[MAX], in[MAX], out[MAX];
bool used[MAX];
int G[MAX][3], rG[MAX][3];
set<int> que;
void add_edge(int u, int x, int y, int z) {
  cube t;
  t.x = x;
  t.y = y;
  t.id = 0;
  int h1 = upper_bound(p, p + n, t) - p, h2 = lower_bound(p, p + n, t) - p;
  if (h1 - h2) {
    h2 = p[h2].id;
    G[u][z] = h2;
    rG[h2][z] = u;
    in[u]++;
    out[h2]++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &p[i].x, &p[i].y);
    p[i].id = i;
  }
  memset(G, -1, sizeof(G));
  memset(rG, -1, sizeof(rG));
  sort(p, p + n);
  for (int i = 0; i < n; ++i) {
    if (p[i].y) {
      add_edge(p[i].id, p[i].x - 1, p[i].y - 1, 0);
      add_edge(p[i].id, p[i].x, p[i].y - 1, 1);
      add_edge(p[i].id, p[i].x + 1, p[i].y - 1, 2);
    }
  }
  for (int i = 0; i < n; ++i) {
    bool flag = false;
    for (int j = 0; j < 3; ++j) {
      if (rG[i][j] != -1 && in[rG[i][j]] == 1) flag = true;
    }
    if (!flag) que.insert(i);
  }
  for (int i = 0; i < n; ++i) {
    int t;
    if (i & 1) {
      t = *que.begin();
      que.erase(que.begin());
    } else {
      set<int>::iterator it = que.end();
      --it;
      t = *it;
      que.erase(it);
    }
    perm[i] = t;
    used[t] = true;
    for (int j = 0; j < 3; ++j) {
      int v = rG[t][j];
      if (v != -1 && !used[v]) {
        in[v]--;
        if (in[v] == 1) {
          for (int k = 0; k < 3; ++k) {
            if (G[v][k] != -1 && !used[G[v][k]]) {
              if (que.find(G[v][k]) == que.end()) continue;
              que.erase(que.find(G[v][k]));
            }
          }
        }
      }
    }
    for (int j = 0; j < 3; ++j) {
      int v = G[t][j];
      if (v != -1 && !used[v]) {
        --out[v];
        bool flag = false;
        for (int k = 0; k < 3; ++k) {
          if (rG[v][k] != -1 && !used[rG[v][k]] && in[rG[v][k]] == 1)
            flag = true;
        }
        if (!flag) que.insert(v);
      }
    }
  }
  long long ans = 0, s = 1;
  for (int i = n - 1; i >= 0; --i) {
    ans += s * perm[i] % mod;
    if (ans >= mod) ans -= mod;
    s = s * n % mod;
  }
  printf("%I64d\n", ans);
  return 0;
}
