#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 5e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
vector<int> add[2 * maxn], rem[2 * maxn];
int par[maxn], siz[maxn], edges[maxn];
int root(int v) { return v == par[v] ? v : par[v] = root(par[v]); }
void unite(int a, int b) {
  a = root(a), b = root(b);
  if (a == b) {
    edges[a]++;
    return;
  }
  if (siz[a] < siz[b]) swap(a, b);
  par[b] = a;
  edges[a] += edges[b] + 1;
  siz[a] += siz[b];
}
vector<pii> v;
int who[maxn * 2];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  v.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    int l, r;
    cin >> l >> r;
    who[l] = i;
    add[l].push_back(l);
    rem[r].push_back(l);
    v[i] = pii(l, r);
  }
  sort(v.begin() + 1, v.end());
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    siz[i] = 1;
    edges[i] = 0;
  }
  set<int> se;
  for (int i = 1; i <= 2 * n; i++) {
    for (int lo : rem[i]) {
      se.erase(lo);
      auto it = se.upper_bound(lo);
      while (it != se.end()) {
        unite(who[lo], who[*it]);
        if (siz[root(who[lo])] - 1 < edges[root(who[lo])])
          return cout << "NO\n", 0;
        ++it;
      }
    }
    for (int lo : add[i]) {
      se.insert(lo);
    }
  }
  if (siz[root(1)] != n)
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
