#include <bits/stdc++.h>
using namespace std;
inline int rint() {
  int a;
  scanf("%d", &a);
  return a;
}
inline long long rll() {
  long long a;
  scanf("%lld", &a);
  return a;
}
inline double rdouble() {
  double a;
  scanf("%lf", &a);
  return a;
}
long long gcd(long long a, long long b) { return (b) ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long pow(long long a, long long b, long long q) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % q;
    a = a * a % q;
    b >>= 1;
  }
  return ans;
}
const long long mod = 1e9 + 9;
pair<int, int> p[100005];
map<pair<int, int>, int> mp;
set<int> s;
vector<int> v;
bool check(int t) {
  int x = p[t].first, y = p[t].second;
  for (int i = x - 1; i <= x + 1; i++)
    if (mp.count(make_pair(i, y + 1)) != 0) {
      int cnt = 0;
      for (int j = i - 1; j <= i + 1; j++)
        if (mp.count(make_pair(j, y)) != 0) cnt++;
      if (cnt == 1) return false;
    }
  return true;
}
int main() {
  int n = rint();
  for (int i = 0; i < n; i++) p[i].first = rint(), p[i].second = rint();
  for (int i = 0; i < n; i++) mp[make_pair(p[i].first, p[i].second)] = i;
  for (int i = 0; i < n; i++)
    if (check(i)) s.insert(i);
  for (int i = 1; i <= n; i++) {
    int temp = 0;
    if (i % 2 == 1) {
      while (!check(*s.rbegin())) s.erase(*s.rbegin());
      temp = *s.rbegin();
    } else {
      while (!check(*s.begin())) s.erase(*s.begin());
      temp = *s.begin();
    }
    v.push_back(temp);
    s.erase(temp);
    mp.erase(make_pair(p[temp].first, p[temp].second));
    int x = p[temp].first, y = p[temp].second;
    for (int i = x - 1; i <= x + 1; i++)
      if (mp.count(make_pair(i, y - 1)) != 0 && check(mp[make_pair(i, y - 1)]))
        s.insert(mp[make_pair(i, y - 1)]);
  }
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) ans = (ans * n % mod + v[i]) % mod;
  cout << ans << endl;
  return 0;
}
