#include <bits/stdc++.h>
using namespace std;
struct cube {
  long long ind, dl, dr, dd;
};
vector<long long> sol, p;
set<pair<long long, long long> > s;
set<long long> canget;
map<pair<long long, long long>, long long> goind;
map<long long, pair<long long, long long> > gocoord;
pair<long long, long long> t;
vector<cube> v;
void pows(long long n) {
  p.push_back(1);
  for (long long i = 0; i < 1000000; ++i)
    p.push_back((p[i] * n) % (1000 * 1000 * 1000 + 9));
}
bool can_I_get_a_cube(long long i) {
  pair<long long, long long> poz = gocoord[i];
  pair<long long, long long> uu = make_pair(poz.first, poz.second + 1),
                             ul = make_pair(poz.first - 1, poz.second + 1),
                             ur = make_pair(poz.first + 1, poz.second + 1);
  pair<long long, long long> l = make_pair(poz.first - 1, poz.second),
                             ll = make_pair(poz.first - 2, poz.second),
                             r = make_pair(poz.first + 1, poz.second),
                             rr = make_pair(poz.first + 2, poz.second);
  if ((!s.count(l) && !s.count(ll) && s.count(ul)) ||
      (!s.count(r) && !s.count(rr) && s.count(ur)) ||
      (!s.count(l) && !s.count(r) && s.count(uu)))
    return false;
  return true;
}
void pizdim(long long i) {
  pair<long long, long long> poz = gocoord[i];
  s.erase(s.find(poz));
  canget.erase(canget.find(i));
  pair<long long, long long> dd = make_pair(poz.first, poz.second - 1),
                             dl = make_pair(poz.first - 1, poz.second - 1),
                             dr = make_pair(poz.first + 1, poz.second - 1);
  pair<long long, long long> l = make_pair(poz.first - 1, poz.second),
                             ll = make_pair(poz.first - 2, poz.second),
                             r = make_pair(poz.first + 1, poz.second),
                             rr = make_pair(poz.first + 2, poz.second);
  if (s.count(l) && !can_I_get_a_cube(goind[l]) && canget.count(goind[l]))
    canget.erase(canget.find(goind[l]));
  if (s.count(r) && !can_I_get_a_cube(goind[r]) && canget.count(goind[r]))
    canget.erase(canget.find(goind[r]));
  if (s.count(ll) && !can_I_get_a_cube(goind[ll]) && canget.count(goind[ll]))
    canget.erase(canget.find(goind[ll]));
  if (s.count(rr) && !can_I_get_a_cube(goind[rr]) && canget.count(goind[rr]))
    canget.erase(canget.find(goind[rr]));
  if (s.count(dd) && can_I_get_a_cube(goind[dd])) canget.insert(goind[dd]);
  if (s.count(dl) && can_I_get_a_cube(goind[dl])) canget.insert(goind[dl]);
  if (s.count(dr) && can_I_get_a_cube(goind[dr])) canget.insert(goind[dr]);
  sol.push_back(i);
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> t.first >> t.second;
    t.first += (1000 * 1000 * 1000 + 9) + (1000 * 1000 * 1000 + 9);
    t.second += (1000 * 1000 * 1000 + 9) + (1000 * 1000 * 1000 + 9);
    s.insert(t);
    gocoord[i] = t;
    goind[t] = i;
  }
  for (long long i = 0; i < n; ++i)
    if (can_I_get_a_cube(i)) canget.insert(i);
  pows(n);
  for (long long i = 0; i < n; ++i)
    if (!(i % 2))
      pizdim(*(--canget.end()));
    else
      pizdim(*canget.begin());
  long long x = 0;
  for (long long i = 0; i < n; ++i) {
    x += sol[i] * p[n - i - 1];
    x %= (1000 * 1000 * 1000 + 9);
  }
  cout << x;
}
