#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
int n;
pair<long long, long long> 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) {
      if (!used[to]) dfs(to, v);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < int(n); i++) scanf("%d%d", &a[i].first, &a[i].second);
  vector<pair<long long, long long> > evs;
  for (int i = 0; i < int(n); i++) {
    evs.push_back(make_pair(a[i].first, i));
    evs.push_back(make_pair(a[i].second, i));
  }
  sort((evs).begin(), (evs).end());
  int cnt = 0;
  set<pair<long long, long long> > cur;
  for (auto it : evs) {
    if (cnt >= n) break;
    if (cur.count(it)) {
      cur.erase(it);
    } else {
      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(make_pair(a[i].second, i));
    }
  }
  dfs(0);
  puts(cnt == n - 1 && count(used, used + n, 1) == n ? "YES" : "NO");
}
