#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
map<pair<int, int>, int> mp;
pair<int, int> p[MAXN];
int a[MAXN];
set<int> st;
set<int>::iterator it;
int link[MAXN];
bool used[MAXN];
const int MOD = 1e9 + 9;
int num[MAXN];
void check(int x, int y) {
  pair<int, int> p = make_pair(x, y);
  if (mp.find(p) == mp.end()) return;
  int id = mp[p];
  if (used[id]) return;
  if (link[id] != -1) return;
  int cnt = 0;
  for (int i = -1; i <= 1; i++) {
    if (mp.find(make_pair(x + i, y - 1)) != mp.end() &&
        !used[mp[make_pair(x + i, y - 1)]])
      cnt++;
  }
  if (cnt == 1) {
    for (int i = -1; i <= 1; i++)
      if (mp.find(make_pair(x + i, y - 1)) != mp.end() &&
          !used[mp[make_pair(x + i, y - 1)]]) {
        int id2 = mp[make_pair(x + i, y - 1)];
        if (link[id] != -1) continue;
        link[id] = id2;
        num[id2]++;
        st.erase(id2);
      }
  }
  return;
}
int main() {
  int n;
  cin >> n;
  memset(link, -1, sizeof(link));
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
    mp[p[i]] = i;
    st.insert(i);
  }
  for (int i = 0; i < n; i++) check(p[i].first, p[i].second);
  for (int i = 0; i < n; i++) {
    int id;
    if (i % 2 == 0) {
      it = st.end();
      it--;
      id = *it;
    } else {
      it = st.begin();
      id = *it;
    }
    a[i] = id;
    used[id] = true;
    st.erase(id);
    if (link[id] != -1) {
      num[link[id]]--;
      if (num[link[id]] == 0) st.insert(link[id]);
    }
    check(p[id].first - 1, p[id].second + 1);
    check(p[id].first, p[id].second + 1);
    check(p[id].first + 1, p[id].second + 1);
  }
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res = res * n % MOD;
    res = (res % MOD + a[i]) % MOD;
  }
  cout << res << endl;
  return 0;
}
