#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const vector<int> mods = {998244353, 1000000007, 1000000009};
const long long inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class... K>
using umap = unordered_map<K...>;
template <class... K>
using uset = unordered_set<K...>;
long long n, nt;
vector<vector<long long> > evs;
umap<long long, pair<long long, long long> > e;
long long par[500100], rnk[500100];
long long fnd(long long x) {
  if (par[x] != x) {
    par[x] = fnd(par[x]);
  }
  return par[x];
}
void unn(long long x, long long y) {
  long long rx = fnd(x), ry = fnd(y);
  if (rx == ry) return;
  if (rnk[rx] < rnk[ry])
    par[rx] = ry;
  else if (rnk[rx] > rnk[ry])
    par[ry] = rx;
  else {
    rnk[rx]++;
    par[ry] = rx;
  }
}
bool tr(long long x, long long y) {
  if (fnd(x) == fnd(y))
    return 1;
  else {
    nt--;
    unn(x, y);
    return 0;
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.precision(12);
  cin >> n;
  nt = n;
  for (long long i = (0); i < (n); ++i) {
    long long a, b;
    cin >> a >> b;
    evs.push_back({a, i, 0});
    evs.push_back({b, i, 1});
    par[i] = i;
    e[i] = {a, b};
  }
  sort(begin(evs), end(evs));
  set<pair<long long, long long> > cur;
  for (auto& ev : evs) {
    if (!ev[2])
      cur.insert({ev[0], ev[1]});
    else {
      cur.erase({e[ev[1]].first, ev[1]});
      for (auto j = cur.upper_bound({e[ev[1]].first, 0}); j != end(cur); j++) {
        if (e[j->second].first < e[ev[1]].first) continue;
        if (tr(ev[1], j->second)) {
          cout << "NO\n";
          return 0;
        }
      }
    }
  }
  if (nt == 1)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
