#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MOD = 1e9 + 9;
vector<int> v;
int X[N], Y[N];
map<pair<int, int>, int> M;
set<int> S;
int stability(int x, int y) {
  int i = M[make_pair(x, y)];
  if (i == 0) return 3;
  int ans = 0;
  if (M[make_pair(x - 1, y - 1)]) ans++;
  if (M[make_pair(x, y - 1)]) ans++;
  if (M[make_pair(x + 1, y - 1)]) ans++;
  return ans;
}
bool canBeRemoved(int i) {
  int x = X[i], y = Y[i];
  i = M[make_pair(x, y)];
  if (i == 0) return 0;
  return stability(x - 1, y + 1) >= 2 and stability(x, y + 1) >= 2 and
         stability(x + 1, y + 1) >= 2;
}
void _remove(int i) {
  int x = X[i], y = Y[i];
  M[make_pair(x, y)] = 0;
  v.push_back(i);
  S.erase(i);
  S.insert(M[make_pair(x - 1, y - 1)]);
  S.insert(M[make_pair(x, y - 1)]);
  S.insert(M[make_pair(x + 1, y - 1)]);
  S.erase(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> X[i] >> Y[i];
    M[make_pair(X[i], Y[i])] = i;
    S.insert(i);
  }
  for (int i = 0; i < m; i++) {
    if (i & 1) {
      while (not canBeRemoved(*S.begin())) {
        S.erase(S.begin());
      }
      _remove(*S.begin());
    } else {
      auto iter = S.end();
      iter--;
      while (not canBeRemoved(*iter)) {
        S.erase(iter);
        iter = S.end();
        iter--;
      }
      _remove(*iter);
    }
  }
  long long ans = 0;
  for (auto it : v) {
    ans = (ans * m + it - 1) % MOD;
  }
  cout << ans << "\n";
  return 0;
}
