#include <bits/stdc++.h>
using namespace std;
int n, perm[100002];
set<int> g[100002];
set<int> init;
pair<int, int> nodes[100002];
map<pair<int, int>, int> mid;
int bad[100002];
int pw[100002];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> nodes[i].first >> nodes[i].second;
    mid[nodes[i]] = i + 1;
  }
  for (int i = 0; i < n; i++) {
    int x = nodes[i].first;
    int y = nodes[i].second;
    if (y == 0) continue;
    int id1 = mid[pair<int, int>(x - 1, y - 1)];
    int id2 = mid[pair<int, int>(x, y - 1)];
    int id3 = mid[pair<int, int>(x + 1, y - 1)];
    if (id1 > 0) g[i + 1].insert(id1);
    if (id2 > 0) g[i + 1].insert(id2);
    if (id3 > 0) g[i + 1].insert(id3);
    if (g[i + 1].size() == 1) bad[*g[i + 1].begin()]++;
  }
  for (int i = 0; i < n; i++)
    if (!bad[i + 1]) init.insert(i + 1);
  int sz = 0;
  while (init.size() > 0) {
    int cur;
    if (sz % 2 == 1) {
      cur = *init.begin();
    } else {
      cur = *--init.end();
    }
    init.erase(cur);
    perm[sz++] = cur;
    if (g[cur].size() == 1 && --bad[*g[cur].begin()] == 0)
      init.insert(*g[cur].begin());
    int x = nodes[cur - 1].first;
    int y = nodes[cur - 1].second;
    mid[pair<int, int>(x, y)] = 0;
    int id1 = mid[pair<int, int>(x - 1, y + 1)];
    int id2 = mid[pair<int, int>(x, y + 1)];
    int id3 = mid[pair<int, int>(x + 1, y + 1)];
    if (id1 > 0) {
      if (g[id1].find(cur) == g[id1].end())
        while (1)
          ;
      g[id1].erase(cur);
      if (g[id1].size() == 0)
        while (1)
          ;
      if (g[id1].size() == 1) {
        init.erase(*g[id1].begin());
        bad[*g[id1].begin()]++;
      }
    }
    if (id2 > 0) {
      if (g[id2].find(cur) == g[id2].end())
        while (1)
          ;
      g[id2].erase(cur);
      if (g[id2].size() == 0)
        while (1)
          ;
      if (g[id2].size() == 1) {
        init.erase(*g[id2].begin());
        bad[*g[id2].begin()]++;
      }
    }
    if (id3 > 0) {
      if (g[id3].find(cur) == g[id3].end())
        while (1)
          ;
      g[id3].erase(cur);
      if (g[id3].size() == 0)
        while (1)
          ;
      if (g[id3].size() == 1) {
        init.erase(*g[id3].begin());
        bad[*g[id3].begin()]++;
      }
    }
  }
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = 1LL * n * pw[i - 1] % 1000000009;
  int ret = 0;
  for (int i = 0; i < n; i++) {
    ret = (ret + 1LL * (perm[i] - 1) * pw[n - 1 - i]) % 1000000009;
  }
  cout << ret << endl;
  return 0;
}
