#include <bits/stdc++.h>
using namespace std;
int mo = 1e9 + 7;
int n;
int L[500005], R[500005];
vector<int> id;
int dsu[500005];
set<int> S;
int ID[1000005];
bool cmp(int a, int b) { return L[a] < L[b]; }
int f(int u) {
  if (dsu[u] != u) return dsu[u] = f(dsu[u]);
  return u;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &L[i], &R[i]);
    id.push_back(i);
    dsu[i] = i;
    ID[L[i]] = i;
    ID[R[i]] = i;
  }
  sort(id.begin(), id.end(), cmp);
  for (int i = 0; i < n; i++) {
    int a = id[i];
    while (!S.empty()) {
      auto it = S.begin();
      int u = *it;
      if (u < L[a]) {
        S.erase(it);
      } else
        break;
    }
    int r = R[a];
    for (auto it : S) {
      int v = it;
      if (v > r) break;
      int b = ID[v];
      if (f(a) != f(b)) {
        int pa = f(a), pb = f(b);
        if (pa > pb) swap(pa, pb);
        dsu[pa] = pb;
      } else {
        printf("NO\n");
        return 0;
      }
    }
    S.insert(r);
  }
  for (int i = 1; i <= n; i++) {
    if (f(i) != f(1)) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
