#include <bits/stdc++.h>
using namespace std;
class dsu {
  vector<int> p;

 public:
  dsu(int n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }
  int get(int v) { return (v == p[v] ? v : p[v] = get(p[v])); }
  void unite(int u, int v) { p[get(u)] = get(v); }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> l(2 * n, -1), r(2 * n, -1), L(n);
  set<pair<int, int>> s;
  dsu g(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    L[i] = a;
    l[a] = i;
    r[b] = i;
  }
  int edg = 0;
  for (int i = 0; i < 2 * n; ++i) {
    if (l[i] != -1) {
      s.emplace(L[l[i]], l[i]);
    } else {
      s.erase({L[r[i]], r[i]});
      for (auto it = s.rbegin(); it != s.rend(); ++it) {
        if (it->first < L[r[i]]) {
          break;
        }
        int x = it->second;
        if (g.get(r[i]) == g.get(x)) {
          cout << "NO";
          return 0;
        } else {
          g.unite(r[i], x);
          ++edg;
        }
      }
    }
  }
  cout << (edg == n - 1 ? "YES" : "NO");
  return 0;
}
