#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7, mod = 1000 * 1000 * 1000 + 9;
map<pair<int, int>, int> num;
int d[N], x[N], y[N], X[] = {-1, 1, 0, 2, -2};
long long ans;
bool mark[N];
set<int> s;
void update(int i) {
  d[i] = 0;
  for (int k = 0; k < 3; k++)
    if (mark[num[{x[i] + X[k], y[i] - 1}]]) d[i]++;
}
bool good(int i) {
  if (mark[i] == 0) return 0;
  for (int k = 0; k < 3; k++)
    if (mark[num[{x[i] + X[k], y[i] + 1}]] &&
        d[num[{x[i] + X[k], y[i] + 1}]] == 1)
      return 0;
  return 1;
}
void remove(int i) {
  s.erase(i);
  vector<int> v;
  for (int k = 0; k < 5; k++) update(num[{x[i] + X[k], y[i] + 1}]);
  for (int k = 0; k < 5; k++)
    if (good(num[{x[i] + X[k], y[i] - 1}]))
      s.insert(num[{x[i] + X[k], y[i] - 1}]);
  for (int k = 0; k < 5; k++)
    if (mark[num[{x[i] + X[k], y[i]}]] && !good(num[{x[i] + X[k], y[i]}]))
      v.push_back(num[{x[i] + X[k], y[i]}]);
  for (auto j : v) s.erase(j);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    num[{x[i], y[i]}] = i;
    mark[i] = 1;
  }
  for (int i = 1; i <= n; i++) update(i);
  for (int i = 1; i <= n; i++)
    if (good(i)) s.insert(i);
  int t = 0;
  while (!s.empty()) {
    int r;
    if (t & 1)
      r = *s.begin();
    else
      r = *s.rbegin();
    t++;
    mark[r] = 0;
    remove(r);
    ans = (ans * n + r - 1) % mod;
  }
  cout << ans << endl;
}
