#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int m;
  cin >> m;
  set<pair<int, pair<int, int> > > S;
  map<pair<int, int>, int> M;
  const int dx[3] = {1, 0, -1};
  vector<pair<int, int> > coor;
  for (int t = 0; t < m; t++) {
    int x, y;
    cin >> x >> y;
    M[make_pair(x, y)] = t;
    coor.push_back(make_pair(x, y));
  }
  for (int t = 0; t < m; t++) {
    int x = coor[t].first, y = coor[t].second;
    bool good = 1;
    for (int i = 0; i < 3; i++) {
      int nx = x + dx[i], ny = y + 1;
      if (M.count(make_pair(nx, ny))) {
        int down = 0;
        for (int j = 0; j < 3; j++)
          if (M.count(make_pair(nx + dx[j], ny - 1))) down++;
        if (down == 1) {
          good = 0;
          break;
        }
      }
    }
    if (good) S.insert(make_pair(t, coor[t]));
  }
  int turn = 1;
  long long res = 0;
  const int MOD = int(1e9) + 9;
  while (!S.empty()) {
    auto now = turn == 0 ? *S.begin() : *S.rbegin();
    int x = now.second.first, y = now.second.second;
    res = (res * m + now.first) % MOD;
    S.erase(now);
    M.erase(make_pair(x, y));
    for (int i = 0; i < 3; i++) {
      int nx = x + dx[i], ny = y + 1;
      if (M.count(make_pair(nx, ny))) {
        int down = 0;
        pair<int, int> downp;
        for (int j = 0; j < 3; j++)
          if (M.count(make_pair(nx + dx[j], ny - 1)))
            down++, downp = make_pair(nx + dx[j], ny - 1);
        if (down == 1) S.erase(make_pair(M[downp], downp));
      }
      ny = y - 1;
      if (M.count(make_pair(nx, ny))) {
        int up = 0;
        for (int j = 0; j < 3; j++) {
          int nnx = nx + dx[j], nny = ny + 1;
          if (M.count(make_pair(nnx, nny))) {
            int down = 0;
            for (int k = 0; k < 3; k++)
              if (M.count(make_pair(nnx + dx[k], nny - 1))) down++;
            if (down == 1) up++;
          }
        }
        if (up == 0)
          S.insert(make_pair(M[make_pair(nx, ny)], make_pair(nx, ny)));
      }
    }
    turn ^= 1;
  }
  cout << res << '\n';
  return 0;
}
