#include <bits/stdc++.h>
using namespace std;
int a[1000010];
int beg[500010];
int f[500010];
set<int> S;
int get(int x) {
  if (x == f[x]) return x;
  return f[x] = get(f[x]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    a[l] = a[r] = i;
  }
  for (int i = 1; i <= n; i++) f[i] = i;
  int cnt = 0;
  int num = n;
  for (int i = 1; i <= 2 * n; i++) {
    if (!beg[a[i]]) {
      beg[a[i]] = i;
      S.insert(i);
    } else {
      for (auto it = (++S.find(beg[a[i]])); it != S.end(); it++) {
        cnt++;
        int p = get(a[i]);
        int q = get(a[*it]);
        if (p != q) num--;
        f[p] = q;
      }
      S.erase(beg[a[i]]);
      beg[a[i]] = 0;
      if (cnt > n - 1) break;
    }
  }
  if (cnt > n - 1 || num != 1)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
