#include <bits/stdc++.h>
using namespace std;
const int Nmax = 5e5 + 5;
int dsu[Nmax];
int components;
int root(int x) {
  if (x == dsu[x]) {
    return x;
  }
  return dsu[x] = root(dsu[x]);
}
void join(int x, int y) {
  int rx = root(x);
  int ry = root(y);
  if (rx != ry) {
    dsu[rx] = ry;
    --components;
  }
}
int main(void) {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int> > ends;
  ends.reserve(2 * n);
  vector<char> used(n, 0);
  for (int i = 0; i < (int)(n); i++) {
    int l, r;
    cin >> l >> r;
    ends.emplace_back(l, i);
    ends.emplace_back(r, i);
  }
  sort(ends.begin(), ends.end());
  iota(dsu, dsu + n + 1, 0);
  components = n;
  vector<int> cur;
  cur.reserve(n + 1);
  int edges = 0;
  for (const auto &[_, i] : ends) {
    if (!used[i]) {
      cur.push_back(i);
      used[i] = 1;
    } else {
      int j;
      for (j = cur.size() - 1; cur[j] != i; j--) {
        ++edges;
        if (edges >= n) {
          cout << "NO\n";
          return 0;
        }
        join(i, cur[j]);
      }
      for (; j + 1 < (int)cur.size(); j++) {
        swap(cur[j], cur[j + 1]);
      }
      cur.pop_back();
    }
  }
  if (components == 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
