#include <bits/stdc++.h>
using namespace std;
vector<int> par;
int root(int x) { return (x == par[x] ? x : par[x] = root(par[x])); }
bool uni(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return false;
  par[x] = y;
  return true;
}
int main() {
  int n, i, j;
  cin >> n;
  par.resize(n + 1);
  for (i = 0; i < n; i++) par[i] = i;
  vector<pair<int, int> > arr(2 * n);
  vector<int> fir(n + 1), sec(n + 1);
  for (i = 0, j = 1; i < 2 * n; i += 2, j++) {
    cin >> arr[i].first >> arr[i + 1].first;
    arr[i].second = j;
    arr[i + 1].second = -j;
    fir[j] = arr[i].first;
    sec[j] = arr[i + 1].first;
  }
  sort(arr.begin(), arr.end());
  bool res = true;
  set<pair<int, int> > s;
  set<pair<int, int> >::iterator it;
  pair<int, int> p;
  for (i = 0, j = 0; i < 2 * n; i++) {
    if (arr[i].second < 0) {
      s.erase(pair<int, int>(arr[i].first, -arr[i].second));
    } else {
      for (it = s.begin(); it != s.end(); it++) {
        p = *it;
        if (p.first > sec[arr[i].second]) break;
        if (!uni(arr[i].second, p.second)) {
          res = false;
          break;
        } else
          j++;
      }
      s.insert(pair<int, int>(sec[arr[i].second], arr[i].second));
    }
  }
  if (!res || j < n - 1)
    cout << "NO\n";
  else
    cout << "YES\n";
}
