#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010001;
map<int, int> hs;
pair<int, int> p[maxn];
int f[maxn];
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> p[i].first >> p[i].second;
  for (int i = 0; i < n; ++i) f[i] = i;
  sort(p, p + n);
  for (int i = 0; i < n; ++i) {
    int u = p[i].first;
    while (1) {
      auto it = hs.upper_bound(u);
      if (it == hs.end() || it->first > p[i].second) break;
      int p = i, q = it->second;
      if (find(p) == find(q)) {
        puts("NO");
        return 0;
      }
      u = it->first;
      f[find(p)] = find(q);
    }
    hs[p[i].second] = i;
  }
  for (int i = 0; i < n; ++i)
    if (find(i) != find(0)) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}
