#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000 * 1000 * 1000 + 9;
const long long int N = 1e5 + 10;
map<pair<long long int, long long int>, pair<long long int, long long int> > m;
long long int n;
set<long long int> st;
long long int dx[3] = {-1, 0, 1};
long long int x[N], y[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    m[make_pair(x[i], y[i])] = make_pair(i, 0);
  }
  for (long long int i = 1; i <= n; i++) {
    long long int cnt = 0;
    for (long long int j = 0; j < 3; j++)
      if (m[make_pair(x[i] + dx[j], y[i] - 1)].first != 0) cnt++;
    m[make_pair(x[i], y[i])] = make_pair(i, cnt);
  }
  for (long long int i = 1; i <= n; i++) {
    bool flag = 1;
    for (long long int j = 0; j < 3; j++) {
      pair<long long int, long long int> p =
          m[make_pair(x[i] + dx[j], y[i] + 1)];
      if (p.first != 0 && p.second == 1) flag = 0;
    }
    if (flag) st.insert(i);
  }
  long long int ans = 0;
  long long int o = 0;
  while (st.size()) {
    long long int ind;
    if (o % 2 == 0) {
      set<long long int>::iterator it = st.end();
      it--;
      ind = *it;
      st.erase(it);
    } else {
      ind = *st.begin();
      st.erase(st.begin());
    }
    ans = (ans * n % MOD + (ind - 1)) % MOD;
    m[make_pair(x[ind], y[ind])] = make_pair(0, 0);
    for (long long int i = 0; i < 3; i++) {
      long long int Y = y[ind] + 1;
      long long int X = x[ind] + dx[i];
      pair<long long int, long long int> pa = m[make_pair(X, Y)];
      if (pa.first == 0) continue;
      pa.second--;
      if (pa.second == 1) {
        for (long long int j = 0; j < 3; j++) {
          pair<long long int, long long int> p = m[make_pair(X + dx[j], Y - 1)];
          if (p.first != 0) st.erase(p.first);
        }
      }
      m[make_pair(X, Y)] = pa;
    }
    for (long long int i = 0; i < 3; i++) {
      long long int Y = y[ind] - 1;
      long long int X = x[ind] + dx[i];
      pair<long long int, long long int> pa = m[make_pair(X, Y)];
      if (pa.first == 0) continue;
      bool flag = 1;
      for (long long int j = 0; j < 3; j++) {
        pair<long long int, long long int> p = m[make_pair(X + dx[j], Y + 1)];
        if (p.first != 0 && p.second == 1) flag = 0;
      }
      if (flag) st.insert(pa.first);
    }
    o++;
  }
  cout << ans;
  return 0;
}
