#include <bits/stdc++.h>
const int maxn = 5e5 + 10;
const int maxm = 1e5 + 10;
const long long int mod = 1e9 + 7;
const long long int INF = 1e18 + 100;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
using namespace std;
int n, m;
int cas, tol, T;
int fa[maxn];
pair<int, int> p[maxn];
set<pair<int, int> > st;
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
bool bind(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return 0;
  fa[x] = y;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
    fa[i] = i;
  }
  sort(p + 1, p + 1 + n);
  st.clear();
  int sz = 0, f = 1;
  for (int i = 1; i <= n; i++) {
    auto pos = st.lower_bound({p[i].first, -1});
    for (auto j = pos; j != st.end(); j++) {
      if ((*j).first > p[i].second) break;
      sz++;
      if (sz == n || !bind(i, (*j).second)) {
        f = 0;
        break;
      }
    }
    if (!f) break;
    st.insert({p[i].second, i});
  }
  set<int> ans;
  for (int i = 1; i <= n; i++) ans.insert(find(i));
  puts(ans.size() == 1 && f ? "YES" : "NO");
  return 0;
}
