#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 1e9 + 9;
int x[maxn], y[maxn];
bool vis[maxn];
int n;
set<int> S;
vector<int> ans;
unordered_map<long long, int> id;
inline long long key(int a, int b) { return (long long)(a)*mod + (long long)b; }
int arr[maxn][6];
void init() {
  vis[0] = 1;
  for (int i = 1; i <= n; i++) {
    arr[i][0] = id[key(x[i] - 1, y[i] + 1)];
    arr[i][1] = id[key(x[i], y[i] + 1)];
    arr[i][2] = id[key(x[i] + 1, y[i] + 1)];
    arr[i][3] = id[key(x[i] - 1, y[i] - 1)];
    arr[i][4] = id[key(x[i], y[i] - 1)];
    arr[i][5] = id[key(x[i] + 1, y[i] - 1)];
  }
}
inline bool can(int i) {
  if (!vis[arr[i][1]]) {
    if (vis[arr[arr[i][1]][3]] && vis[arr[arr[i][1]][5]]) {
      return 0;
    }
  }
  if (!vis[arr[i][0]]) {
    if (vis[arr[arr[i][0]][3]] && vis[arr[arr[i][0]][4]]) {
      return 0;
    }
  }
  if (!vis[arr[i][2]]) {
    if (vis[arr[arr[i][2]][4]] && vis[arr[arr[i][2]][5]]) {
      return 0;
    }
  }
  return 1;
}
void used(int i) {
  if (!vis[arr[i][0]]) arr[arr[i][0]][5] = 0;
  if (!vis[arr[i][1]]) arr[arr[i][1]][4] = 0;
  if (!vis[arr[i][2]]) arr[arr[i][2]][3] = 0;
  if (!vis[arr[i][3]]) arr[arr[i][3]][2] = 0;
  if (!vis[arr[i][4]]) arr[arr[i][4]][1] = 0;
  if (!vis[arr[i][5]]) arr[arr[i][5]][0] = 0;
}
void era(int i) {
  int p = arr[i][1];
  if (!vis[p]) {
    if (!vis[arr[p][3]]) {
      if (!can(arr[p][3])) S.erase(arr[p][3]);
    }
    if (!vis[arr[p][5]]) {
      if (!can(arr[p][5])) S.erase(arr[p][5]);
    }
  }
  p = arr[i][0];
  if (!vis[p]) {
    if (!vis[arr[p][3]]) {
      if (!can(arr[p][3])) S.erase(arr[p][3]);
    }
    if (!vis[arr[p][4]]) {
      if (!can(arr[p][4])) S.erase(arr[p][4]);
    }
  }
  p = arr[i][2];
  if (!vis[p]) {
    if (!vis[arr[p][4]]) {
      if (!can(arr[p][4])) S.erase(arr[p][4]);
    }
    if (!vis[arr[p][5]]) {
      if (!can(arr[p][5])) S.erase(arr[p][5]);
    }
  }
}
void fin_new(int i) {
  int p = arr[i][4];
  if (!vis[p]) {
    if (can(p)) S.insert(p);
  }
  p = arr[i][3];
  if (!vis[p]) {
    if (can(p)) S.insert(p);
  }
  p = arr[i][5];
  if (!vis[p]) {
    if (can(p)) S.insert(p);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", x + i, y + i);
    id[key(x[i], y[i])] = i;
  }
  init();
  for (int i = 1; i <= n; i++) {
    if (can(i)) S.insert(i);
  }
  while (!S.empty()) {
    int idx = *S.rbegin();
    ans.push_back(idx);
    S.erase((++S.rbegin()).base());
    used(idx);
    era(idx);
    fin_new(idx);
    if (!S.empty()) {
      idx = *S.begin();
      ans.push_back(idx);
      S.erase(S.begin());
      used(idx);
      era(idx);
      fin_new(idx);
    }
  }
  long long bas = 1, A = 0;
  for (int i = ans.size() - 1; i >= 0; i--) {
    A = (A + bas * (long long)(ans[i] - 1)) % mod;
    bas = bas * (long long)n % mod;
  }
  printf("%lld\n", A);
}
