#include <bits/stdc++.h>
using namespace std;
struct CUBE {
  int x, y, num;
} cube[100005];
struct POINT {
  int x, y;
  friend bool operator<(POINT a, POINT b) {
    if (a.x < b.x)
      return 1;
    else if (a.x == b.x)
      return a.y < b.y;
    else
      return 0;
  }
};
map<POINT, int> mp;
inline void iCube(POINT p, int val) { mp[p] = val; }
int qCube(POINT p) {
  if (mp.find(p) != mp.end()) {
    return mp[p];
  } else
    return -1;
}
bool cCube(POINT p) {
  POINT a, b, c, left, right, lleft, rright;
  a.x = p.x - 1;
  a.y = p.y + 1;
  b.x = p.x;
  b.y = p.y + 1;
  c.x = p.x + 1;
  c.y = p.y + 1;
  left.x = p.x - 1;
  left.y = p.y;
  right.x = p.x + 1;
  right.y = p.y;
  lleft.x = left.x - 1;
  lleft.y = left.y;
  rright.x = right.x + 1;
  rright.y = right.y;
  if (qCube(a) == -1 && qCube(b) == -1 && qCube(c) == -1) {
    return 1;
  }
  if (qCube(a) != -1) {
    if (qCube(left) == -1 && qCube(lleft) == -1) return 0;
  }
  if (qCube(b) != -1) {
    if (qCube(left) == -1 && qCube(right) == -1) return 0;
  }
  if (qCube(c) != -1) {
    if (qCube(right) == -1 && qCube(rright) == -1) return 0;
  }
  return 1;
}
inline void dCube(POINT p) { mp.erase(p); }
set<int> s;
vector<int> ans;
int dx[] = {-2, -1, -1, 0, 1, 1, 2};
int dy[] = {0, 0, -1, -1, -1, 0, 0};
void solve(POINT p) {
  int i;
  POINT tmp;
  for (i = 0; i < 7; i++) {
    tmp.x = p.x + dx[i];
    tmp.y = p.y + dy[i];
    int num = qCube(tmp);
    if (num == -1) continue;
    if (cCube(tmp)) {
      s.insert(num);
    } else {
      if (s.find(num) != s.end()) {
        s.erase(num);
      }
    }
  }
}
int main() {
  int m, i;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &cube[i].x, &cube[i].y);
    cube[i].num = i;
    POINT tmp;
    tmp.x = cube[i].x;
    tmp.y = cube[i].y;
    iCube(tmp, i);
  }
  for (i = 0; i < m; i++) {
    POINT p;
    p.x = cube[i].x;
    p.y = cube[i].y;
    if (cCube(p)) {
      s.insert(i);
    }
  }
  set<int>::iterator it1;
  set<int>::reverse_iterator it2;
  POINT tmp;
  for (i = 0; i < m; i++) {
    if (i & 1) {
      it1 = s.begin();
      ans.push_back(*it1);
      tmp.x = cube[*it1].x;
      tmp.y = cube[*it1].y;
      dCube(tmp);
      s.erase(*it1);
      solve(tmp);
    } else {
      it2 = s.rbegin();
      ans.push_back(*it2);
      tmp.x = cube[*it2].x;
      tmp.y = cube[*it2].y;
      dCube(tmp);
      s.erase(*it2);
      solve(tmp);
    }
  }
  int len = ans.size();
  long long res = 0;
  for (i = 0; i < len; i++) {
    res = (1LL * res * m % 1000000009 + ans[i]) % 1000000009;
  }
  cout << res << endl;
  return 0;
}
