#include <bits/stdc++.h>
using namespace std;
const int N = (int)5e5 + 9;
int pi[N];
int sz[N];
int fin(int u) {
  if (pi[u] == u) return u;
  return pi[u] = fin(pi[u]);
}
int cnt = 0;
bool unite(int a, int b) {
  a = fin(a);
  b = fin(b);
  if (a == b) return false;
  cnt++;
  if (sz[a] > sz[b]) swap(a, b);
  sz[b] += sz[a];
  pi[a] = b;
  return true;
}
vector<pair<int, int> > ins[2 * N];
vector<pair<int, int> > er[2 * N];
vector<pair<int, int> > tt[2 * N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  int l, r;
  for (int i = 1; i <= n; i++) {
    cin >> l >> r;
    ins[l].push_back(make_pair(i, r));
    er[r].push_back(make_pair(i, l));
    pi[i] = i;
    sz[i] = 1;
  }
  set<pair<int, int> > el;
  for (int i = 1; i <= 2 * n; i++) {
    for (auto x : ins[i]) {
      el.insert(make_pair(i, fin(x.first)));
      tt[x.second].push_back(make_pair(i, fin(x.first)));
    }
    for (auto p : tt[i]) {
      el.erase(p);
    }
    for (auto p : er[i]) {
      auto it = el.lower_bound(make_pair(p.second + 1, -1));
      while (it != el.end()) {
        if (!unite(p.first, it->second)) {
          cout << "NO\n";
          return 0;
        }
        it++;
      }
    }
  }
  if (cnt == n - 1)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
