#include <bits/stdc++.h>
using namespace std;
class P {
 public:
  int x, y;
  P() {}
  P(int xx, int yy) {
    x = xx;
    y = yy;
  }
};
bool operator<(P a, P b) { return a.x != b.x ? a.x < b.x : a.y < b.y; }
int N, D[100010], ret[100010];
P a[100010];
map<P, int> mp;
set<int> st;
vector<int> g[100010];
long long MOD = 1000000009;
bool ok(int i) {
  P curr = a[i];
  for (int d = -1; d <= 1; d++) {
    P next(curr.x + d, curr.y + 1);
    if (mp.count(next) && D[mp[next]] == 1) {
      return false;
    }
  }
  return true;
}
int get(int i) {
  P curr = a[i];
  for (int d = -1; d <= 1; d++) {
    P next(curr.x + d, curr.y - 1);
    if (mp.count(next)) {
      return mp[next];
    }
  }
  assert(false);
}
void remove(int i) {
  mp.erase(a[i]);
  for (int d = -1; d <= 1; d++) {
    P next(a[i].x + d, a[i].y + 1);
    if (mp.count(next)) {
      D[mp[next]]--;
      if (D[mp[next]] == 1) {
        st.erase(get(mp[next]));
      }
    }
  }
  for (int d = -1; d <= 1; d++) {
    P next(a[i].x + d, a[i].y - 1);
    if (mp.count(next) && ok(mp[next])) {
      st.insert(mp[next]);
    }
  }
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    P curr(x, y);
    a[i] = curr;
    mp[curr] = i;
  }
  for (int i = 0; i < N; i++) {
    P curr = a[i];
    if (curr.y == 0) continue;
    for (int d = -1; d <= 1; d++) {
      P next(curr.x + d, curr.y - 1);
      if (mp.count(next)) {
        D[i]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    P curr = a[i];
    if (ok(i)) st.insert(i);
  }
  for (int i = 0; i < N; i++) {
    if ((i & 1) == 0) {
      ret[i] = *(st.rbegin());
      remove(ret[i]);
    } else {
      ret[i] = *(st.begin());
      remove(ret[i]);
    }
    st.erase(ret[i]);
  }
  long long ans = 0, base = 1;
  for (int i = N - 1; i >= 0; i--) {
    ans = (ans + base * ret[i]) % MOD;
    base = (base * N) % MOD;
  }
  cout << ans << endl;
  return 0;
}
