#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int N = 500010;
int n;
pair<int, int> a[N];
vector<int> g[N];
bool used[N];
void dfs(int v, int p = -1) {
  used[v] = true;
  for (auto to : g[v]) {
    if (to == p || used[to]) {
      continue;
    }
    dfs(to, v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  vector<pair<int, int> > evs;
  for (int i = 0; i < n; ++i) {
    evs.push_back({a[i].first, i});
    evs.push_back({a[i].second, i});
  }
  sort(evs.begin(), evs.end());
  int cnt = 0;
  set<pair<int, int> > cur;
  for (auto it : evs) {
    if (cnt >= n) {
      break;
    }
    if (cur.count(it)) {
      cur.erase(it);
      continue;
    }
    int i = it.second;
    int r = a[i].second;
    for (auto jt : cur) {
      if (jt.first > r) {
        break;
      }
      int j = jt.second;
      g[i].push_back(j);
      g[j].push_back(i);
      ++cnt;
      if (cnt >= n) {
        break;
      }
    }
    cur.insert({a[i].second, i});
  }
  dfs(0);
  cout << (cnt == n - 1 && count(used, used + n, 1) == n ? "YES" : "NO")
       << "\n";
  return 0;
}
