#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int mod = 1e9 + 9;
struct BLOCKS {
  int x, y, num;
  bool operator<(const BLOCKS &b) const {
    if (y == b.y) return x < b.x;
    return y < b.y;
  }
} a[MAXN];
vector<int> G[MAXN];
int up[MAXN], down[MAXN], ans[MAXN], tot, ltot, x[2][MAXN], num[2][MAXN], n;
bool vis[MAXN];
bool check(int x) {
  bool f = 1;
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    if (!vis[y])
      if (a[y].y > a[x].y && down[y] <= 1) f = 0;
  }
  return f;
}
struct comp1 {
  bool operator()(int x, int y) { return a[x].num < a[y].num; }
};
struct comp2 {
  bool operator()(int x, int y) { return a[x].num > a[y].num; }
};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].x, &a[i].y), a[i].num = i;
  sort(a + 1, a + n + 1);
  int o = 0, cur = 1;
  for (int i = 1; i <= n; i++)
    if (a[i].y == 0) {
      x[o][++tot] = a[i].x;
      num[o][tot] = i;
    } else {
      if (a[i].y != a[i - 1].y) o ^= 1, ltot = tot, tot = 0, cur = 1;
      while (cur <= ltot && x[o ^ 1][cur] < a[i].x - 1) cur++;
      while (cur <= ltot && x[o ^ 1][cur] <= a[i].x + 1) {
        G[i].push_back(num[o ^ 1][cur]);
        G[num[o ^ 1][cur]].push_back(i);
        down[i]++;
        up[num[o ^ 1][cur]]++;
        cur++;
      }
      x[o][++tot] = a[i].x;
      num[o][tot] = i;
      cur = max(1, cur - 2);
    }
  priority_queue<int, vector<int>, comp1> q1;
  priority_queue<int, vector<int>, comp2> q2;
  for (int i = 1; i <= n; i++)
    if (check(i)) q1.push(i), q2.push(i);
  for (int i = 1; i <= n; i++) {
    int x = 0;
    if (i & 1) {
      x = q1.top();
      q1.pop();
      while (vis[x] || !check(x)) x = q1.top(), q1.pop();
    } else {
      x = q2.top();
      q2.pop();
      while (vis[x] || !check(x)) x = q2.top(), q2.pop();
    }
    vis[x] = 1;
    ans[i] = a[x].num;
    for (int j = 0; j < G[x].size(); j++) {
      int y = G[x][j];
      if (vis[y]) continue;
      if (a[y].y < a[x].y) up[y]--;
      if (a[y].y > a[x].y) down[y]--;
      if (check(y)) {
        q1.push(y);
        q2.push(y);
      }
    }
  }
  long long tot = 0, fac = 1;
  for (int i = n; i >= 1; i--) {
    (tot += fac * (ans[i] - 1) % mod) %= mod;
    fac = fac * n % mod;
  }
  printf("%lld\n", tot);
  return 0;
}
