#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
map<pair<int, int>, int> m;
bool can(int x, int y) {
  return y == 0 || m.count(make_pair(x - 1, y - 1)) ||
         m.count(make_pair(x, y - 1)) || m.count(make_pair(x + 1, y - 1));
}
bool check(int x, int y) {
  int pos = m[make_pair(x, y)];
  m.erase(make_pair(x, y));
  bool st = true;
  if (m.count(make_pair(x - 1, y + 1))) {
    st = min(st, can(x - 1, y + 1));
  }
  if (m.count(make_pair(x, y + 1))) {
    st = min(st, can(x, y + 1));
  }
  if (m.count(make_pair(x + 1, y + 1))) {
    st = min(st, can(x + 1, y + 1));
  }
  m[make_pair(x, y)] = pos;
  return st;
}
vector<int> ans;
const int maxn = (int)1e5 + 10;
const long long p = (int)1e9 + 9;
pair<int, int> v[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    m[make_pair(x, y)] = i;
    v[i] = make_pair(x, y);
  }
  map<int, pair<int, int> > now;
  for (int i = 0; i < n; i++) {
    if (check(v[i].first, v[i].second)) {
      now[i] = v[i];
    }
  }
  for (int i = 0; i < n; i++) {
    int pos = (*now.begin()).first;
    if (i % 2 == 0) {
      pos = (*now.rbegin()).first;
    }
    pair<int, int> f = now[pos];
    if (!check(f.first, f.second)) {
      now.erase(pos);
      i--;
      continue;
    }
    ans.push_back(pos);
    now.erase(pos);
    m.erase(f);
    f.second--;
    f.first--;
    if (m.count(f)) {
      if (check(f.first, f.second)) {
        now[m[f]] = f;
      }
    }
    f.first++;
    if (m.count(f)) {
      if (check(f.first, f.second)) {
        now[m[f]] = f;
      }
    }
    f.first++;
    if (m.count(f)) {
      if (check(f.first, f.second)) {
        now[m[f]] = f;
      }
    }
  }
  long long t = 0;
  for (int i = 0; i < (int)ans.size(); i++) {
    t *= n;
    t += ans[i];
    t %= p;
  }
  cout << t << endl;
  return 0;
}
