#include <bits/stdc++.h>
using namespace std;
long long T, m, n, q, w, mi, ma, cnt, s, t, fi, cc, e, r, z, x, an;
struct aa {
  long long x, y;
  bool operator<(const aa &l) const {
    return (x < l.x || (x == l.x && y < l.y));
  }
};
aa a[100010];
map<aa, long long> map1;
vector<long long> b[100010];
vector<long long> c[100010];
priority_queue<long long> pqmax;
priority_queue<long long, vector<long long>, greater<long long> > pqmin;
long long outDeg[100010];
long long ans[100010];
bool used[100010];
bool removable(long long q) {
  bool ret = true;
  aa tempaa;
  tempaa.y = a[q].y + 1;
  for (long long j = -1; j <= 1; j++) {
    tempaa.x = a[q].x + j;
    if (map1.count(tempaa) != 0) {
      long long tempNum = map1[tempaa];
      if (outDeg[tempNum] == 1) ret = false;
    }
  }
  return ret;
}
int main() {
  cin >> m;
  for (long long i = 0; i < m; i++) {
    cin >> q >> w;
    a[i].x = q;
    a[i].y = w;
    map1[a[i]] = i;
  }
  for (long long i = 0; i < m; i++) {
    if (a[i].y == 0) continue;
    aa tempaa;
    tempaa.y = a[i].y - 1;
    for (long long j = -1; j <= 1; j++) {
      tempaa.x = j + a[i].x;
      if (map1.count(tempaa) != 0) {
        long long tempNum = map1[tempaa];
        b[i].push_back(tempNum);
        outDeg[i]++;
        c[tempNum].push_back(i);
      }
    }
  }
  for (long long i = 0; i < m; i++)
    if (removable(i)) {
      pqmax.push(i);
      pqmin.push(i);
    }
  for (long long i = 0; i < m; i++) {
    if (i % 2 == 0) {
      while (used[pqmax.top()] || !removable(pqmax.top())) {
        pqmax.pop();
      }
      ans[i] = pqmax.top();
      pqmax.pop();
    } else {
      while (used[pqmin.top()] || !removable(pqmin.top())) {
        pqmin.pop();
      }
      ans[i] = pqmin.top();
      pqmin.pop();
    }
    used[ans[i]] = true;
    outDeg[ans[i]] = 0;
    for (long long j = 0; j < c[ans[i]].size(); j++) outDeg[c[ans[i]][j]]--;
    for (long long j = 0; j < b[ans[i]].size(); j++) {
      if (removable(b[ans[i]][j])) {
        pqmax.push(b[ans[i]][j]);
        pqmin.push(b[ans[i]][j]);
      }
    }
  }
  an = 0;
  w = 1;
  for (long long i = m - 1; i >= 0; i--) {
    an = (an + (ans[i] * w) % 1000000009LL) % 1000000009LL;
    w = (m * w) % 1000000009LL;
  }
  cout << an << endl;
  return 0;
}
