#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> mp;
set<int> s;
int m;
pair<int, int> p[100001];
long long ans;
const long long md = 1e9 + 9;
int up[3][2] = {-1, 1, 0, 1, 1, 1};
int dwn[3][2] = {-1, -1, 0, -1, 1, -1};
int cnt(int ind) {
  int res = 0;
  int x = p[ind].first, y = p[ind].second;
  for (int i = 0; i < 3; i++) {
    int xx = x + dwn[i][0], yy = y + dwn[i][1];
    if (mp.find(make_pair(xx, yy)) != mp.end()) res++;
  }
  return res;
}
bool chk(int ind) {
  int x = p[ind].first, y = p[ind].second;
  for (int i = 0; i < 3; i++) {
    int xx = x + up[i][0], yy = y + up[i][1];
    if (mp.find(make_pair(xx, yy)) != mp.end()) {
      int d = mp[make_pair(xx, yy)];
      if (cnt(d) <= 1) {
        return false;
      }
    }
  }
  return true;
}
void work(int ind) {
  ans = (ans * (long long)m % md + ind) % md;
  int x = p[ind].first, y = p[ind].second;
  mp.erase(make_pair(x, y));
  for (int i = 0; i < 3; i++) {
    int xx = x + dwn[i][0], yy = y + dwn[i][1];
    if (mp.find(make_pair(xx, yy)) != mp.end()) {
      int d = mp[make_pair(xx, yy)];
      if (chk(d)) {
        s.insert(d);
      }
    }
  }
}
void mx() {
  set<int>::iterator it;
  int x;
  while (!s.empty()) {
    it = s.end();
    it--;
    if (chk(*it)) {
      x = *it;
      s.erase(it);
      break;
    }
    s.erase(it);
  }
  work(x);
}
void mn() {
  set<int>::iterator it;
  int x;
  while (!s.empty()) {
    it = s.begin();
    if (chk(*it)) {
      x = *it;
      s.erase(it);
      break;
    }
    s.erase(it);
  }
  work(x);
}
int main() {
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
    mp[make_pair(p[i].first, p[i].second)] = i;
    s.insert(i);
  }
  for (int i = 0; i < m; i++) {
    if (i & 1)
      mn();
    else
      mx();
  }
  printf("%lld", ans);
  return 0;
}
