#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
map<int, int> Mp;
int F[MAXN];
pair<int, int> Pa[MAXN];
int n;
int GetF(int x) { return (x == F[x]) ? x : F[x] = GetF(F[x]); }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) F[i] = i;
  for (int i = 1; i <= n; i++) cin >> Pa[i].first >> Pa[i].second;
  sort(Pa + 1, Pa + 1 + n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    auto it = Mp.lower_bound(Pa[i].first);
    while (it != Mp.end() && it->first < Pa[i].second) {
      int tl = GetF(i);
      int tr = GetF(it->second);
      if (tl == tr || cnt >= n) {
        cout << "NO\n";
        return 0;
      } else {
        cnt++;
        F[tl] = tr;
      }
      ++it;
    }
    Mp[Pa[i].second] = i;
  }
  if (cnt != n - 1)
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
