#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const long long MOD = 1e9 + 9;
int n;
long long ans[MAXN];
struct Node {
  int x, y;
  int up[4], down[4];
  Node() {
    memset(up, -1, sizeof(up));
    memset(down, -1, sizeof(down));
  }
  Node(int _x, int _y) : x(_x), y(_y) {}
  int getdown() {
    int res = 0;
    for (int i = 1; i <= 3; i++)
      if (down[i] != -1) res++;
    return res;
  }
  friend bool operator<(Node a, Node b) {
    if (a.x == b.x) return a.y < b.y;
    return a.x < b.x;
  }
} arr[MAXN];
set<int> c, nc;
map<Node, int> pos;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].x >> arr[i].y;
    pos[Node(arr[i].x, arr[i].y)] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 1;
    for (int j = arr[i].x - 1; j <= arr[i].x + 1; j++) {
      arr[i].up[cnt] = pos[Node(j, arr[i].y + 1)] - 1;
      arr[i].down[cnt] = pos[Node(j, arr[i].y - 1)] - 1;
      cnt++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (arr[i].getdown() > 1) continue;
    for (int j = 1; j <= 3; j++) {
      int v = arr[i].down[j];
      if (v == -1) continue;
      nc.insert(v);
    }
  }
  for (int i = 0; i < n; i++)
    if (nc.find(i) == nc.end()) c.insert(i);
  int tot = 0;
  int x;
  while (!c.empty()) {
    if (!(tot & 1))
      x = *c.rbegin();
    else
      x = *c.begin();
    c.erase(x);
    ans[tot++] = x;
    for (int i = 1; i <= 3; i++) {
      int v = arr[x].up[i];
      if (v == -1) continue;
      arr[v].down[4 - i] = -1;
      if (arr[v].getdown() > 1) continue;
      for (int j = 1; j <= 3; j++) {
        int vv = arr[v].down[j];
        if (vv == -1) continue;
        if (c.find(vv) != c.end()) c.erase(vv);
        nc.insert(vv);
      }
    }
    for (int i = 1; i <= 3; i++) {
      int v = arr[x].down[i];
      if (v == -1) continue;
      arr[v].up[4 - i] = -1;
      int flag = 0;
      for (int j = 1; j <= 3; j++) {
        int vv = arr[v].up[j];
        if (vv == -1) continue;
        if (arr[vv].getdown() <= 1) flag = 1;
      }
      if (!flag) {
        if (nc.find(v) != nc.end()) nc.erase(v);
        c.insert(v);
      }
    }
  }
  long long res = 0;
  for (int i = 0; i < tot; i++) res = (res * n + ans[i]) % MOD;
  cout << res << endl;
  return 0;
}
