#include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int dcmp(long double a, long double b) {
  return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(int num, int idx) { return num ^ (1 << idx); }
void FS() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long long mod = 1e9 + 9;
const int N = 100009;
int x[N], y[N];
int m;
map<pair<int, int>, int> mb;
set<int> st;
bool check2(int mx, int my) {
  int id = mb[make_pair(mx, my)];
  int cnt = 0;
  if (mb.find(make_pair(mx, my - 1)) != mb.end()) cnt++;
  if (mb.find(make_pair(mx + 1, my - 1)) != mb.end()) cnt++;
  if (mb.find(make_pair(mx - 1, my - 1)) != mb.end()) cnt++;
  if (cnt > 1) return 1;
  return 0;
}
void check(int mx, int my, int id) {
  int cnt = 0;
  if (mb.find(make_pair(mx, my + 1)) != mb.end() && check2(mx, my + 1) == 0)
    cnt++;
  if (mb.find(make_pair(mx + 1, my + 1)) != mb.end() &&
      check2(mx + 1, my + 1) == 0)
    cnt++;
  if (mb.find(make_pair(mx - 1, my + 1)) != mb.end() &&
      check2(mx - 1, my + 1) == 0)
    cnt++;
  if (cnt == 0) st.insert(id);
}
vector<int> v1;
long long conv_m() {
  long long ans = 0;
  for (int i = 0; i < ((int)(v1).size()); i++) {
    int val = v1[i];
    ans = ((ans * m) % mod + val) % mod;
  }
  return ans;
}
void check3(int mx, int my) {
  int id = mb[make_pair(mx, my)];
  int cnt = 0;
  if (mb.find(make_pair(mx, my - 1)) != mb.end()) cnt++;
  if (mb.find(make_pair(mx + 1, my - 1)) != mb.end()) cnt++;
  if (mb.find(make_pair(mx - 1, my - 1)) != mb.end()) cnt++;
  if (cnt > 1) return;
  if (mb.find(make_pair(mx, my - 1)) != mb.end()) {
    auto it = st.find(mb[make_pair(mx, my - 1)]);
    if (it != st.end()) st.erase(it);
  }
  if (mb.find(make_pair(mx + 1, my - 1)) != mb.end()) {
    auto it = st.find(mb[make_pair(mx + 1, my - 1)]);
    if (it != st.end()) st.erase(it);
  }
  if (mb.find(make_pair(mx - 1, my - 1)) != mb.end()) {
    auto it = st.find(mb[make_pair(mx - 1, my - 1)]);
    if (it != st.end()) st.erase(it);
  }
}
void update(int id) {
  int mx = x[id];
  int my = y[id];
  auto it = mb.find(make_pair(x[id], y[id]));
  if (it != mb.end()) mb.erase(it);
  if (mb.find(make_pair(mx, my + 1)) != mb.end()) check3(mx, my + 1);
  if (mb.find(make_pair(mx + 1, my + 1)) != mb.end()) check3(mx + 1, my + 1);
  if (mb.find(make_pair(mx - 1, my + 1)) != mb.end()) check3(mx - 1, my + 1);
  if (mb.find(make_pair(mx, my - 1)) != mb.end()) {
    check(mx, my - 1, mb[make_pair(mx, my - 1)]);
  }
  if (mb.find(make_pair(mx + 1, my - 1)) != mb.end()) {
    check(mx + 1, my - 1, mb[make_pair(mx + 1, my - 1)]);
  }
  if (mb.find(make_pair(mx - 1, my - 1)) != mb.end()) {
    check(mx - 1, my - 1, mb[make_pair(mx - 1, my - 1)]);
  }
}
int main() {
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    mb[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < m; i++) {
    int mx = x[i];
    int my = y[i];
    check(mx, my, i);
  }
  int t = 1;
  int T = m;
  while (T--) {
    if (t == 1) {
      auto it = st.end();
      it--;
      v1.push_back((*it));
      update((*it));
      st.erase(it);
    } else {
      auto it = st.begin();
      v1.push_back((*it));
      update((*it));
      st.erase(it);
    }
    t = !t;
  }
  cout << conv_m() << endl;
}
