#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
int n, x[100005], y[100005], pw[100005];
set<pair<int, int> > alls;
set<int> cannow;
map<pair<int, int>, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    alls.insert(make_pair(x[i], y[i]));
    mp[make_pair(x[i], y[i])] = i;
  }
  for (int i = 0; i < n; i++) {
    int t = 0;
    if (alls.find(make_pair(x[i] - 1, y[i] + 1)) != alls.end()) t |= 1;
    if (alls.find(make_pair(x[i], y[i] + 1)) != alls.end()) t |= 2;
    if (alls.find(make_pair(x[i] + 1, y[i] + 1)) != alls.end()) t |= 4;
    bool g1 = alls.find(make_pair(x[i] - 2, y[i])) != alls.end();
    bool g2 = alls.find(make_pair(x[i] - 1, y[i])) != alls.end();
    int h = 0;
    if (g1 || g2) h |= 1;
    g1 = alls.find(make_pair(x[i] + 1, y[i])) != alls.end();
    if (g1 || g2) h |= 2;
    g2 = alls.find(make_pair(x[i] + 2, y[i])) != alls.end();
    if (g1 || g2) h |= 4;
    bool flag = true;
    for (int j = 0; j < 3; j++)
      if ((t & (1 << j)) && !(h & (1 << j))) {
        flag = false;
        break;
      }
    if (flag) cannow.insert(i);
  }
  pw[0] = 1;
  for (int i = 1; i < n; i++)
    pw[i] = (int)(((long long)pw[i - 1] * (long long)n) % mod);
  int ismx = 1;
  int cnt = n - 1;
  long long res = 0ll;
  while (!cannow.empty()) {
    int i, tt;
    if (ismx) {
      i = *cannow.rbegin();
    } else {
      i = *cannow.begin();
    }
    cannow.erase(cannow.find(i));
    alls.erase(alls.find(make_pair(x[i], y[i])));
    res = ((long long)res + ((long long)pw[cnt] * (long long)i) % mod) % mod;
    cnt--;
    ismx = 1 - ismx;
    tt = i;
    vector<int> v;
    if (alls.find(make_pair(x[i] - 2, y[i])) != alls.end())
      v.push_back(mp[make_pair(x[i] - 2, y[i])]);
    if (alls.find(make_pair(x[i] - 1, y[i])) != alls.end())
      v.push_back(mp[make_pair(x[i] - 1, y[i])]);
    if (alls.find(make_pair(x[i] + 1, y[i])) != alls.end())
      v.push_back(mp[make_pair(x[i] + 1, y[i])]);
    if (alls.find(make_pair(x[i] + 2, y[i])) != alls.end())
      v.push_back(mp[make_pair(x[i] + 2, y[i])]);
    for (int _ = 0; _ < v.size(); _++) {
      i = v[_];
      int t = 0;
      if (alls.find(make_pair(x[i] - 1, y[i] + 1)) != alls.end()) t |= 1;
      if (alls.find(make_pair(x[i], y[i] + 1)) != alls.end()) t |= 2;
      if (alls.find(make_pair(x[i] + 1, y[i] + 1)) != alls.end()) t |= 4;
      bool g1 = alls.find(make_pair(x[i] - 2, y[i])) != alls.end();
      bool g2 = alls.find(make_pair(x[i] - 1, y[i])) != alls.end();
      int h = 0;
      if (g1 || g2) h |= 1;
      g1 = alls.find(make_pair(x[i] + 1, y[i])) != alls.end();
      if (g1 || g2) h |= 2;
      g2 = alls.find(make_pair(x[i] + 2, y[i])) != alls.end();
      if (g1 || g2) h |= 4;
      bool flag = true;
      for (int j = 0; j < 3; j++)
        if ((t & (1 << j)) && !(h & (1 << j))) {
          flag = false;
          break;
        }
      if (!flag && cannow.find(i) != cannow.end()) cannow.erase(i);
    }
    v.clear();
    i = tt;
    if (alls.find(make_pair(x[i] - 1, y[i] - 1)) != alls.end())
      v.push_back(mp[make_pair(x[i] - 1, y[i] - 1)]);
    if (alls.find(make_pair(x[i], y[i] - 1)) != alls.end())
      v.push_back(mp[make_pair(x[i], y[i] - 1)]);
    if (alls.find(make_pair(x[i] + 1, y[i] - 1)) != alls.end())
      v.push_back(mp[make_pair(x[i] + 1, y[i] - 1)]);
    for (int _ = 0; _ < v.size(); _++) {
      i = v[_];
      int t = 0;
      if (alls.find(make_pair(x[i] - 1, y[i] + 1)) != alls.end()) t |= 1;
      if (alls.find(make_pair(x[i], y[i] + 1)) != alls.end()) t |= 2;
      if (alls.find(make_pair(x[i] + 1, y[i] + 1)) != alls.end()) t |= 4;
      bool g1 = alls.find(make_pair(x[i] - 2, y[i])) != alls.end();
      bool g2 = alls.find(make_pair(x[i] - 1, y[i])) != alls.end();
      int h = 0;
      if (g1 || g2) h |= 1;
      g1 = alls.find(make_pair(x[i] + 1, y[i])) != alls.end();
      if (g1 || g2) h |= 2;
      g2 = alls.find(make_pair(x[i] + 2, y[i])) != alls.end();
      if (g1 || g2) h |= 4;
      bool flag = true;
      for (int j = 0; j < 3; j++)
        if ((t & (1 << j)) && !(h & (1 << j))) {
          flag = false;
          break;
        }
      if (flag) cannow.insert(i);
    }
  }
  printf("%I64d\n", res);
  return 0;
}
