#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() {
    cin.sync_with_stdio(1);
    cin.tie(0);
  }
} _;
vector<int> adj[100100];
int dx[3] = {-1, 0, 1};
int dy[3] = {-1, -1, -1};
vector<int> par[100100];
vector<int> child[100100];
bool killed[100100];
map<pair<int, int>, int> R;
bool check(int u) {
  for (auto p : par[u]) {
    if (child[p].size() == 1) {
      return false;
    }
  }
  return true;
}
int main(int argc, char **argv) {
  int N;
  cin >> N;
  vector<pair<int, int>> P;
  for (int i = (0); i < (N); ++i) {
    int first, second;
    cin >> first >> second;
    P.push_back(make_pair(first, second));
    R[P.back()] = i;
  }
  for (int i = (0); i < (N); ++i) {
    int first = P[i].first;
    int second = P[i].second;
    for (int k = (0); k < (3); ++k) {
      int nx = first + dx[k];
      int ny = second + dy[k];
      if (R.count(make_pair(nx, ny))) {
        int j = R[make_pair(nx, ny)];
        par[j].push_back(i);
        child[i].push_back(j);
      }
    }
  }
  priority_queue<int> maxQ;
  priority_queue<int, vector<int>, greater<int>> minQ;
  for (int i = (0); i < (N); ++i) {
    bool removable = true;
    for (auto v : par[i]) {
      if (child[v].size() == 1) {
        removable = false;
      }
    }
    if (removable) {
      minQ.push(i);
      maxQ.push(i);
    }
  }
  vector<int> res;
  for (int i = (0); i < (N); ++i) {
    int p;
    if (i % 2 == 0) {
      while (true) {
        p = maxQ.top();
        maxQ.pop();
        if (killed[p] || !check(p)) continue;
        break;
      }
    } else {
      while (true) {
        p = minQ.top();
        minQ.pop();
        if (killed[p] || !check(p)) continue;
        break;
      }
    }
    killed[p] = true;
    res.push_back(p);
    for (auto u : par[p]) {
      for (auto j = child[u].begin(); j != child[u].end(); j++)
        if (*j == p) {
          child[u].erase(j);
          break;
        }
    }
    for (auto u : child[p]) {
      for (auto j = par[u].begin(); j != par[u].end(); j++)
        if (*j == p) {
          par[u].erase(j);
          break;
        }
      if (check(u)) {
        minQ.push(u);
        maxQ.push(u);
      }
    }
  }
  long long val = 0;
  for (int i = (0); i < ((int)res.size()); ++i) {
    val = (((val * N) % 1000000009) + res[i]) % 1000000009;
  }
  cout << val;
  return 0;
}
