#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
vector<int> v[N];
bool viz[N];
int cnt;
pair<long long, long long> a[N];
void dfs(int x) {
  viz[x] = 1;
  cnt++;
  for (auto it : v[x])
    if (!viz[it]) dfs(it);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<pair<long long, long long> > ev;
  int n, nredge = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    ev.push_back({a[i].first, i});
    ev.push_back({a[i].second, i});
  }
  sort(ev.begin(), ev.end());
  set<pair<long long, long long> > s;
  for (auto it : ev) {
    if (nredge >= n) break;
    if (s.count(it))
      s.erase(it);
    else {
      int i = it.second;
      long long r = a[i].second;
      for (auto it : s) {
        if (it.first > r) break;
        int j = it.second;
        v[i].push_back(j);
        v[j].push_back(i);
        nredge++;
        if (nredge >= n) break;
      }
      s.insert({r, i});
    }
  }
  dfs(1);
  if (cnt == n && nredge == n - 1)
    cout << "YES\n";
  else
    cout << "NO\n";
}
