#include <bits/stdc++.h>
using namespace std;
int n;
map<pair<int, int>, int> a, rtops;
map<int, pair<int, int> > tops;
int ans[111111];
inline int support(pair<int, int> c) {
  if (c.second == 0) return 100;
  if (!a.count(c)) return 100;
  return (a.count(make_pair(c.first - 1, c.second - 1))) +
         (a.count(make_pair(c.first, c.second - 1))) +
         (a.count(make_pair(c.first + 1, c.second - 1)));
}
inline bool can_remove(pair<int, int> c) {
  return support(make_pair(c.first - 1, c.second + 1)) > 1 &&
         support(make_pair(c.first - 0, c.second + 1)) > 1 &&
         support(make_pair(c.first + 1, c.second + 1)) > 1;
}
const int mod = 1000000009;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int first, second;
    scanf("%d%d", &first, &second);
    a[make_pair(first, second)] = i;
  }
  for (map<pair<int, int>, int>::iterator it = a.begin(); it != a.end(); ++it) {
    if (can_remove(it->first)) {
      tops[it->second] = it->first;
      rtops[it->first] = it->second;
    }
  }
  for (int act = 0; (int)(a).size(); ++act) {
    pair<int, int> r = make_pair(0, 0);
    map<int, pair<int, int> >::iterator it;
    if (act % 2 == 0) {
      it = tops.end();
      --it;
    } else {
      it = tops.begin();
    }
    r = it->second;
    ans[act] = it->first;
    tops.erase(it);
    rtops.erase(rtops.find(r));
    a.erase(a.find(r));
    for (int sx = -3; sx <= 3; ++sx) {
      for (int sy = -2; sy <= 2; ++sy) {
        pair<int, int> t = make_pair(r.first + sx, r.second + sy);
        if (a.count(t)) {
          if (can_remove(t)) {
            if (!rtops.count(t)) {
              rtops[t] = a[t];
              tops[a[t]] = t;
            }
          } else {
            if (rtops.count(t)) {
              rtops.erase(rtops.find(t));
              tops.erase(tops.find(a[t]));
            }
          }
        }
      }
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    ret = ((long long)ret * n + ans[i]) % mod;
  }
  cout << ret << endl;
}
