#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
double inff = 1.0 / 0.0;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long int x, y, n, i, z, j, k, w, u, q, m, t;
pair<long long int, long long int> v[1000002];
long long int p[1000002], a[1000002];
map<long long int, long long int> m1;
long long int find_set(long long int x) {
  if (x != p[x]) {
    p[x] = find_set(p[x]);
  }
  return p[x];
}
void union1(long long int x, long long int y) {
  if (a[x] < a[y]) {
    p[x] = y;
    return;
  }
  p[y] = x;
  if (a[x] == a[y]) a[x]++;
}
void solve() {
  cin >> n;
  for (i = (int)1; i < (int)n + 1; i++) cin >> v[i].first >> v[i].second;
  for (i = (int)1; i < (int)n + 1; i++) p[i] = i, a[i] = 1;
  sort(v + 1, v + 1 + n);
  w = 0;
  m1[v[1].second] = 1;
  for (i = (int)2; i < (int)n + 1; i++) {
    auto itr = m1.upper_bound(v[i].first);
    if (itr != m1.end()) {
      for (auto it = itr; it->first < v[i].second and it != m1.end(); it++) {
        long long int x = find_set(i);
        long long int y = find_set(it->second);
        if (x == y) {
          cout << "NO"
               << "\n";
          return;
        }
        union1(x, y);
        w++;
      }
    }
    m1[v[i].second] = i;
  }
  if (w == n - 1) {
    cout << "YES"
         << "\n";
  } else
    cout << "NO"
         << "\n";
}
int main() {
  int TESTS = 1;
  ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  ;
  while (TESTS--) {
    solve();
  }
}
