#include <bits/stdc++.h>
using namespace std;
int fa[500005];
int fi(int a) {
  if (a == fa[a])
    return a;
  else
    return fa[a] = fi(fa[a]);
}
vector<pair<int, int> > ve;
map<int, int> ma;
int main() {
  int t, b, c;
  string ss, s;
  int n;
  ios::sync_with_stdio(false);
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> b >> c;
      ve.push_back({b, c});
      fa[i] = i;
    }
    sort(ve.begin(), ve.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
      while (!ma.empty() && ma.begin()->first < ve[i].first) {
        ma.erase(ma.begin());
      }
      for (auto it = ma.begin(); it != ma.end() && it->first < ve[i].second;
           it++) {
        int x = fi(it->second), y = fi(i);
        if (x == y)
          ans = n;
        else {
          fa[x] = y;
          ans++;
        }
      }
      if (ans == n) break;
      ma[ve[i].second] = i;
    }
    if (ans == n - 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
    ve.clear(), ma.clear();
  }
  return 0;
}
