#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using i32 = int32_t;
using ui32 = uint32_t;
using i64 = int64_t;
using ui64 = uint64_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
static int constexpr dbg = 0;
ll constexpr NM = 1e5 + 9, Mo = 1e9 + 9;
struct C {
  bool rmed;
  int pre, post;
  ll x, y;
} cubs[NM];
int m;
map<pll, int> mp;
bool free(int i) {
  if (cubs[i].rmed) return false;
  if (!cubs[i].post) return true;
  auto x = cubs[i].x, y = cubs[i].y;
  for (int i = -1; i <= 1; ++i) {
    if (mp.count(make_pair(x + i, y + 1))) {
      auto idx = mp[make_pair(x + i, y + 1)];
      if (cubs[idx].pre <= 1) return false;
    }
  }
  return true;
}
int main(int argc, char *argv[]) {
  if (!dbg) {
    std::ios::sync_with_stdio(false);
  }
  cin >> m;
  for (int i = 1; i <= (int)(m); ++i) {
    ll x, y;
    cin >> x >> y;
    cubs[i].x = x;
    cubs[i].y = y;
    mp[make_pair(x, y)] = i;
  }
  for (int i = 1; i <= (int)(m); ++i) {
    ll x, y;
    x = cubs[i].x;
    y = cubs[i].y;
    if (!y) continue;
    for (int j = -1; j <= 1; ++j) {
      if (mp.count(make_pair(x + j, y - 1))) {
        ++cubs[mp[make_pair(x + j, y - 1)]].post;
        ++cubs[i].pre;
      }
    }
  }
  set<int> q;
  for (int i = 1; i <= (int)(m); ++i) {
    if (free(i)) q.insert(i);
  }
  ll res = 0;
  bool mx = true;
  while (!q.empty()) {
    int i;
    if (mx) {
      i = *q.rbegin();
    } else {
      i = *q.begin();
    }
    q.erase(i);
    if (!free(i)) continue;
    mx = !mx;
    do {
      if (dbg) printf("D: %d\n", i);
    } while (0);
    res = (res * m + (i - 1)) % Mo;
    ll x, y;
    x = cubs[i].x, y = cubs[i].y;
    mp.erase(make_pair(x, y));
    cubs[i].rmed = true;
    for (int j = -1; j <= 1; ++j) {
      if (mp.count(make_pair(x + j, y + 1))) {
        auto idx = mp[make_pair(x + j, y + 1)];
        if (cubs[idx].rmed) continue;
        --cubs[idx].pre;
        --cubs[i].post;
        if (free(idx)) q.insert(idx);
      }
    }
    if (!y) continue;
    for (int j = -1; j <= 1; ++j) {
      if (mp.count(make_pair(x + j, y - 1))) {
        auto idx = mp[make_pair(x + j, y - 1)];
        if (cubs[idx].rmed) continue;
        --cubs[idx].post;
        --cubs[i].pre;
        if (free(idx)) q.insert(idx);
      }
    }
  }
  cout << res << '\n';
  return 0;
}
