#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
pair<ll, ll> date[1000000 + 110];
bool cmp(pair<ll, ll> a, pair<ll, ll> b) { return get<1>(a) < get<1>(b); }
ostream& operator<<(ostream& os, pair<ll, ll> a) {
  return os << "(" << get<0>(a) << "," << get<1>(a) << ")";
}
ll lson(ll now) { return now * 2; }
ll rson(ll now) { return now * 2 + 1; }
ll f[1000000 + 110];
ll find(ll n) { return f[n] == 0 ? n : f[n] = find(f[n]); }
bool issame(ll a, ll b) { return find(a) == find(b); }
void merge(ll a, ll b) { f[find(a)] = find(b); }
void debug(ll n) {
  cout << "in debug  "
       << "\n";
  cout << "\n";
}
vector<ll> sum[1000000 * 4 + 110];
unordered_map<ll, ll> pos;
void ins(ll now, ll star, ll fini, ll askbeg, ll askend) {
  if (fini < askbeg or askend < star) return;
  if (askbeg <= star and fini <= askend) {
    sum[now].push_back(pos[askend + 1]);
    return;
  }
  ins(lson(now), star, ((star + fini) / 2), askbeg, askend);
  ins(rson(now), ((star + fini) / 2) + 1, fini, askbeg, askend);
}
ll ask(ll now, ll star, ll fini, ll pos, ll id) {
  if (pos < star or fini < pos) return 0;
  ll ret = sum[now].size();
  for (auto it : sum[now])
    if (issame(it, id)) {
      cout << "NO";
      exit(0);
    } else
      merge(it, id);
  if (star < fini)
    ret += ask(lson(now), star, ((star + fini) / 2), pos, id),
        ret += ask(rson(now), ((star + fini) / 2) + 1, fini, pos, id);
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) cin >> get<0>(date[i]) >> get<1>(date[i]);
  sort(date + 1, date + 1 + n, cmp);
  for (ll i = 1; i <= n; i++) pos[get<1>(date[i])] = i;
  ll ret = 0;
  for (ll i = 1; i <= n and ret < n; i++) {
    ret += ask(1, 0, 2 * n, get<0>(date[i]), i);
    if (get<1>(date[i]) - get<0>(date[i]) >= 2)
      ins(1, 0, 2 * n, get<0>(date[i]) + 1, get<1>(date[i]) - 1);
  }
  cout << (ret == n - 1 ? "YES" : "NO");
  return 0;
}
