#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[600000];
int pa[600000];
int fp(int x) {
  if (x == pa[x]) return x;
  return pa[x] = fp(pa[x]);
}
struct A {
  int s, e, i;
  bool operator<(const A& o) const {
    if (e < o.e) return false;
    return true;
  }
};
A tmp;
priority_queue<A> b;
vector<A> t;
int main() {
  int n, i, j, x, y, ch = 0, k = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a[i].first, &a[i].second);
    pa[i] = i;
  }
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    while (!b.empty() && b.top().e <= a[i].first) b.pop();
    while (!b.empty() && b.top().e < a[i].second) {
      x = fp(i);
      y = fp(b.top().i);
      if (x == y) {
        ch = 1;
        break;
      }
      k++;
      pa[x] = y;
      if (k == n) {
        ch = 1;
        break;
      }
      t.push_back(b.top());
      b.pop();
    }
    if (ch) break;
    for (j = 0; j < t.size(); j++) {
      b.push(t[j]);
    }
    t.clear();
    tmp.s = a[i].first;
    tmp.e = a[i].second;
    tmp.i = i;
    b.push(tmp);
  }
  if (ch || k != n - 1)
    printf("NO");
  else
    printf("YES");
  return 0;
}
