#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000100], cnt, cnt2, flag[1000100], cnt3, last, q[1000100],
    re[1000100];
struct edge {
  int l, r;
} d[1000100];
struct node {
  int v;
  node *next;
} pool[2 * 1000100], *h[1000100];
void addedge(int u, int v) {
  node *p = &pool[++cnt], *q = &pool[++cnt];
  p->v = v;
  p->next = h[u];
  h[u] = p;
  q->v = u;
  q->next = h[v];
  h[v] = q;
}
void dfs(int u) {
  cnt3++;
  flag[u] = 1;
  for (node *p = h[u]; p; p = p->next) {
    if (flag[p->v] == 0) {
      dfs(p->v);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &d[i].l, &d[i].r);
    a[d[i].l] = i;
    a[d[i].r] = i + n;
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (a[i] <= n) {
      q[++last] = a[i];
      re[a[i]] = last;
    } else {
      for (int j = re[a[i] - n] + 1; j <= last; j++) {
        q[j - 1] = q[j];
        re[q[j]]--;
        addedge(a[i] - n, q[j]);
        cnt2++;
        if (cnt2 >= n) {
          printf("NO\n");
          return 0;
        }
      }
      last--;
    }
  }
  if (cnt2 < n - 1) {
    printf("NO\n");
    return 0;
  }
  dfs(1);
  if (cnt3 != n)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
