#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
void chmax(T& a, T b) {
  a = max(a, b);
}
template <class T>
void chmin(T& a, T b) {
  a = min(a, b);
}
#pragma comment(linker, "/STACK:36777216")
const int MOD = ((int)1e9) + 9;
vector<int> e[((int)1e5) + 10], re[((int)1e5) + 10];
int up[((int)1e5) + 10];
int main() {
  int m;
  scanf("%d", &m);
  vector<pair<int, int> > v;
  for (int i = 0; i < (m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v.emplace_back(x, y);
  }
  map<pair<int, int>, int> mp;
  for (int i = 0; i < (m); i++) mp[v[i]] = i;
  for (int i = 0; i < (m); i++) {
    for (int dx = -1; dx <= 1; dx++) {
      auto it = mp.find(pair<int, int>(v[i].first + dx, v[i].second - 1));
      if (it != mp.end()) {
        e[i].push_back(it->second);
        re[it->second].push_back(i);
      }
    }
  }
  for (int i = 0; i < (m); i++)
    for (auto to : e[i]) up[to]++;
  set<int> ids;
  for (int i = 0; i < (m); i++) {
    bool ok = true;
    for (auto fr : re[i])
      if (((int)(e[fr]).size()) == 1) ok = false;
    if (ok) ids.insert(i);
  }
  static bool used[((int)1e5)];
  vector<long long> ans;
  for (int _i = 0; _i < (m); _i++) {
    int ch = -1;
    if (_i % 2 == 0)
      ch = *ids.rbegin();
    else
      ch = *ids.begin();
    ans.push_back(ch);
    ids.erase(ch);
    used[ch] = true;
    static vector<int> check_list;
    check_list.clear();
    for (auto to : e[ch]) {
      if (!used[to]) check_list.push_back(to);
    }
    for (auto par : re[ch]) {
      if (!used[par]) {
        for (auto to : e[par]) {
          if (!used[to]) check_list.push_back(to);
        }
      }
    }
    for (auto o : check_list) {
      bool ok = true;
      for (auto parent : re[o]) {
        if (used[parent]) continue;
        int cnt = 0;
        for (auto to : e[parent]) {
          if (!used[to]) cnt++;
        }
        if (cnt == 1) ok = false;
      }
      if (ok)
        ids.insert(o);
      else {
        auto it = ids.find(o);
        if (it != ids.end()) ids.erase(it);
      }
    }
  }
  long long out = 0;
  for (int i = 0; i < (m); i++) {
    (out = out * m + ans[i]) %= MOD;
  }
  cout << out << endl;
}
