#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 10;
const long long MOD = 1000000009;
long long pw[maxn];
pair<int, int> p[maxn];
map<pair<int, int>, int> mp;
pair<int, int> moveU[] = {make_pair(-1, 1), make_pair(0, 1), make_pair(1, 1)};
pair<int, int> moveD[] = {make_pair(-1, -1), make_pair(0, -1),
                          make_pair(1, -1)};
int d[maxn];
void pre(int n) {
  pw[0] = 1;
  for (int i = 1; i < maxn; i++) pw[i] = (pw[i - 1] * n) % MOD;
}
bool chkDanger(pair<int, int> P) {
  for (int l = 0; l < 3; l++) {
    int cur =
        mp[make_pair(P.first + moveU[l].first, P.second + moveU[l].second)];
    if (cur and d[cur] == 1) return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  pre(n);
  for (int i = 1; i <= n; i++)
    cin >> p[i].first >> p[i].second,
        mp[make_pair(p[i].first, p[i].second)] = i;
  for (int i = 1; i <= n; i++)
    for (int l = 0; l < 3; l++)
      if (mp[make_pair(p[i].first + moveD[l].first,
                       p[i].second + moveD[l].second)])
        d[i]++;
  set<int> st;
  st.clear();
  for (int i = 1; i <= n; i++)
    if (!chkDanger(p[i])) st.insert(i);
  int time = 1;
  vector<int> res(0);
  while (!st.empty()) {
    int cur;
    if (time % 2)
      cur = *(--st.end()), st.erase(--st.end());
    else
      cur = *st.begin(), st.erase(st.begin());
    time++;
    res.push_back(cur - 1);
    mp[p[cur]] = 0;
    for (int l = 0; l < 3; l++) {
      int curUp = mp[make_pair(p[cur].first + moveU[l].first,
                               p[cur].second + moveU[l].second)];
      if (curUp) d[curUp]--;
    }
    for (int l = 0; l < 3; l++) {
      int curDw = mp[make_pair(p[cur].first + moveD[l].first,
                               p[cur].second + moveD[l].second)];
      if (curDw and !chkDanger(p[curDw])) st.insert(curDw);
    }
    pair<int, int> left = p[cur];
    left.first--;
    pair<int, int> right = p[cur];
    right.first++;
    int curLeft = mp[left];
    int curRight = mp[right];
    if (curLeft and chkDanger(left) and st.find(curLeft) != st.end())
      st.erase(st.find(curLeft));
    if (curRight and chkDanger(right) and st.find(curRight) != st.end())
      st.erase(st.find(curRight));
    left.first--;
    right.first++;
    curLeft = mp[left];
    curRight = mp[right];
    if (curLeft and chkDanger(left) and st.find(curLeft) != st.end())
      st.erase(st.find(curLeft));
    if (curRight and chkDanger(right) and st.find(curRight) != st.end())
      st.erase(st.find(curRight));
  }
  reverse(res.begin(), res.end());
  long long ans = 0;
  for (int i = 0; i < res.size(); i++)
    ans = (ans + ((res[i] * pw[i]) % MOD)) % MOD;
  cout << ans << endl;
  return 0;
}
