#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const long long inf = (((long long)1) << 61) + 5;
const int N = 100005;
const int mod = 1000000009;
int x[N], y[N];
map<pair<int, int>, int> mp;
set<int> up[N], down[N];
bool vis[N];
int main() {
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    mp[{x[i], y[i]}] = i;
  }
  for (int i = 0; i < m; i++) {
    for (int j = x[i] - 1; j <= x[i] + 1; j++) {
      map<pair<int, int>, int>::iterator it;
      it = mp.find({j, y[i] - 1});
      if (it != mp.end()) {
        down[i].insert(it->second);
        up[it->second].insert(i);
      }
    }
  }
  for (int i = 0; i < m; i++)
    if (down[i].size() == 1) vis[*down[i].begin()] = true;
  set<int> st;
  for (int i = 0; i < m; i++)
    if (!vis[i]) st.insert(i);
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    int j = i & 1 ? *st.begin() : *st.rbegin();
    st.erase(j);
    ans = (ans * m + j) % mod;
    set<int>::iterator it;
    for (it = up[j].begin(); it != up[j].end(); it++) {
      down[*it].erase(j);
      if (down[*it].size() == 1 && !vis[*down[*it].begin()]) {
        int tmp = *down[*it].begin();
        vis[tmp] = true;
        st.erase(tmp);
      }
    }
    for (it = down[j].begin(); it != down[j].end(); it++) {
      up[*it].erase(j);
      st.insert(*it);
      vis[*it] = false;
      for (int t : up[*it]) {
        if (down[t].size() == 1) {
          vis[*it] = true;
          st.erase(*it);
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
