#include <bits/stdc++.h>
using namespace std;
struct Cube {
  int number;
  long long int x, y;
  Cube() {}
  Cube(int number, int x, int y) {
    this->number = number;
    this->x = x;
    this->y = y;
  }
};
int totalCubes, totalCubesInStructure;
int arrayCubes[500000];
map<pair<int, int>, Cube> structuredCubes;
map<int, Cube> releasebleCubes;
void writeStructure() {
  cout << "Structure: ";
  for (auto i = structuredCubes.begin(); i != structuredCubes.end(); i++) {
    cout << i->second.number << " ";
  }
  cout << endl;
}
void writeReleaseble() {
  cout << "Releaseble: ";
  for (auto i = releasebleCubes.begin(); i != releasebleCubes.end(); i++) {
    cout << i->first << " ";
  }
  cout << endl;
}
void insertCubeToStructure(Cube a) {
  structuredCubes.insert(
      pair<pair<int, int>, Cube>(pair<int, int>(a.x, a.y), a));
}
void insertCubeToReleaseble(Cube a) {
  auto aux = structuredCubes.find(pair<int, int>(a.x, a.y));
  releasebleCubes.insert(pair<int, Cube>(aux->second.number, aux->second));
}
void deletCubeFromStructure(Cube a) {
  structuredCubes.erase(pair<int, int>(a.x, a.y));
}
void deletCubeFromReleaseble(Cube a) {
  auto aux = structuredCubes.find(pair<int, int>(a.x, a.y));
  releasebleCubes.erase(aux->second.number);
}
bool isThereCube(Cube a) {
  map<pair<int, int>, Cube>::iterator structuredAux =
      structuredCubes.find(pair<int, int>(a.x, a.y));
  if (structuredAux != structuredCubes.end()) {
    return true;
  } else {
    return false;
  }
}
int isSustentedBy(Cube a) {
  int count = 0;
  if (isThereCube(Cube(a.number, a.x - 1, a.y - 1))) count++;
  if (isThereCube(Cube(a.number, a.x, a.y - 1))) count++;
  if (isThereCube(Cube(a.number, a.x + 1, a.y - 1))) count++;
  return count;
}
bool isReleaseble(Cube a) {
  bool answ = true;
  answ = answ && (!isThereCube(Cube(a.number, a.x - 1, a.y + 1)) ||
                  isSustentedBy(Cube(a.number, a.x - 1, a.y + 1)) > 1);
  answ = answ && (!isThereCube(Cube(a.number, a.x, a.y + 1)) ||
                  isSustentedBy(Cube(a.number, a.x, a.y + 1)) > 1);
  answ = answ && (!isThereCube(Cube(a.number, a.x + 1, a.y + 1)) ||
                  isSustentedBy(Cube(a.number, a.x + 1, a.y + 1)) > 1);
  return answ;
}
void readD() {
  long long int x, y;
  cin >> totalCubes;
  totalCubesInStructure = totalCubes;
  for (size_t i = 0; i < totalCubes; i++) {
    cin >> x >> y;
    insertCubeToStructure(Cube(i, x, y));
  }
  for (map<pair<int, int>, Cube>::iterator i = structuredCubes.begin();
       i != structuredCubes.end(); i++) {
    if (isReleaseble(i->second)) {
      insertCubeToReleaseble(i->second);
    }
  }
}
void updateCube(Cube a) {
  if (isThereCube(a)) {
    if (isReleaseble(a)) {
      insertCubeToReleaseble(a);
    } else {
      deletCubeFromReleaseble(a);
    }
  }
}
void update(Cube a) {
  updateCube(Cube(a.number, a.x - 2, a.y));
  updateCube(Cube(a.number, a.x - 1, a.y));
  updateCube(Cube(a.number, a.x + 1, a.y));
  updateCube(Cube(a.number, a.x + 2, a.y));
  updateCube(Cube(a.number, a.x - 1, a.y - 1));
  updateCube(Cube(a.number, a.x, a.y - 1));
  updateCube(Cube(a.number, a.x + 1, a.y - 1));
}
void delet(Cube a) {
  deletCubeFromReleaseble(a);
  deletCubeFromStructure(a);
  totalCubesInStructure--;
  update(a);
}
void boyPlay() {
  auto aux = releasebleCubes.rbegin();
  arrayCubes[totalCubesInStructure - 1] = aux->first;
  delet(aux->second);
}
void girlPlay() {
  auto aux = releasebleCubes.begin();
  arrayCubes[totalCubesInStructure - 1] = aux->first;
  delet(aux->second);
}
void play() {
  bool boyTurn = true;
  while (totalCubesInStructure > 0) {
    if (boyTurn) {
      boyPlay();
      boyTurn = false;
    } else {
      girlPlay();
      boyTurn = true;
    }
  }
}
void writeAnsw() {
  long long int answ = 0;
  for (int i = totalCubes - 1; i >= 0; i--) {
    answ = (answ * totalCubes + arrayCubes[i]) % 1000000009;
  }
  cout << answ;
}
int main() {
  readD();
  play();
  writeAnsw();
  return 0;
}
