#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy[] = {0, -1, -1, -1, 0, 1, 1, 1};
const int N = 1000100;
const long long mod = 1000000009LL;
map<pair<long long, long long>, int> m;
int n;
vector<pair<long long, long long> > v;
bool have(int x, int y) {
  if (m.find(pair<long long, long long>(x, y)) == m.end()) return false;
  if (m[pair<long long, long long>(x, y)] == -1) return false;
  return true;
}
int conta(int x, int y) {
  if (!have(x, y)) return 0;
  return have(x - 1, y - 1) + have(x, y - 1) + have(x + 1, y - 1);
}
bool can(int x, int y) {
  if (conta(x - 1, y + 1) == 1) return false;
  if (conta(x, y + 1) == 1) return false;
  if (conta(x + 1, y + 1) == 1) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    m[pair<long long, long long>(a, b)] = i;
    v.push_back(make_pair(a, b));
  }
  set<int> s;
  vector<long long> ans;
  for (int i = 0; i < n; ++i) s.insert(i);
  int f = 1;
  while (!s.empty()) {
    int foo;
    if (f) {
      set<int>::iterator it = s.end();
      it--;
      foo = (*it);
      s.erase(it);
    } else {
      foo = (*s.begin());
      s.erase(s.begin());
    }
    int x = v[foo].first;
    int y = v[foo].second;
    if (!can(x, y)) continue;
    f ^= 1;
    ans.push_back(foo);
    m[pair<long long, long long>(x, y)] = -1;
    for (int i = 0; i < 8; i++) {
      int xx = x + dx[i], yy = y + dy[i];
      if (have(xx, yy)) s.insert(m[pair<long long, long long>(xx, yy)]);
    }
  }
  long long resp = 0;
  long long pot = 1;
  for (int i = n - 1; i >= 0; --i) {
    resp += (pot * ans[i]);
    resp %= mod;
    pot *= n;
    pot %= mod;
  }
  printf("%lld\n", resp);
  return 0;
}
