#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
struct node {
  int lx, ly;
  int val;
  bool operator<(const node &rr) const {
    return make_pair(this->lx, this->ly) < make_pair(rr.lx, rr.ly);
  }
};
set<node> mp;
bool check(node cur) {
  int lx = cur.lx, ly = cur.ly;
  int sup = 0;
  for (int i = -1; i <= 1; i++) {
    sup += (mp.find({lx - i, ly - 1, 0}) != mp.end());
  }
  return (sup > 1);
}
bool free(node cur) {
  int lx = cur.lx, ly = cur.ly;
  bool flag = 1;
  for (int j = -1; j <= 1; j++) {
    auto it = mp.find({lx - j, ly + 1, 0});
    if (it != mp.end()) {
      if (!check(*it)) {
        flag = 0;
        break;
      }
    }
  }
  return flag;
}
struct cmp {
  bool operator()(node ll, node rr) const { return ll.val < rr.val; }
};
int main() {
  int m;
  scanf("%d", &m);
  vector<node> a(m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i].lx, &a[i].ly);
    a[i].val = i;
    mp.insert(a[i]);
  }
  set<node, cmp> s;
  for (int i = 0; i < m; i++) {
    if (free(a[i])) {
      s.insert(a[i]);
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    node cur;
    if (i & 1) {
      auto it = s.begin();
      while (!free(*it)) {
        it = s.erase(it);
      }
      cur = *it;
    } else {
      auto it = s.end();
      while (!free(*(--it))) {
        it = s.erase(it);
      }
      cur = *it;
    }
    ans = (1ll * ans * m) % mod;
    ans = (ans + cur.val) % mod;
    mp.erase(cur);
    s.erase(cur);
    int lx = cur.lx, ly = cur.ly;
    for (int j = -1; j <= 1; j++) {
      auto jt = mp.find({lx + j, ly - 1, 0});
      if (jt != mp.end()) {
        if (free(*jt)) {
          s.insert(*jt);
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
