#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const int MAXN = 600010;
set<int> g[MAXN];
int n, t, m, k;
int visited[MAXN];
void dfs(int i) {
  visited[i] = 1;
  for (auto x : g[i])
    if (!visited[x]) dfs(x);
  return;
}
int main() {
  cin >> n;
  pair<int, int> a[n];
  for (long long i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a, a + n);
  int res = 0;
  set<pair<int, pair<int, int> > > s;
  for (long long i = 0; i < n; i++) {
    auto x =
        s.lower_bound({a[i].first, {-((long long)1e15), -((long long)1e15)}});
    while (x != s.begin()) {
      s.erase(s.begin());
    }
    auto it =
        s.upper_bound({a[i].second, {-((long long)1e15), -((long long)1e15)}});
    x = s.begin();
    while (x != it) {
      g[i].insert(x->second.second);
      g[x->second.second].insert(i);
      res++;
      if (res >= n) {
        cout << "NO"
             << "\n";
        return 0;
      }
      x++;
    }
    s.insert({a[i].second, {a[i].first, i}});
  }
  dfs(0);
  for (long long i = 0; i < n; i++) {
    if (!visited[i]) {
      cout << "NO";
      return 0;
    }
  }
  if (res == n - 1)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
