#include <bits/stdc++.h>
using namespace std;
const int MAX = 1005000;
int p[MAX];
void init(int n) {
  for (int i = 0; i < int(n + 1); i++) p[i] = i;
}
int getS(int u) {
  if (u == p[u])
    return u;
  else
    return (p[u] = getS(p[u]));
}
void join(int u, int v) {
  u = getS(u);
  v = getS(v);
  if (u == v) return;
  p[u] = v;
}
pair<int, int> LR[MAX];
const int NMAX = 1010000, MMAX = 11002000;
int first[MMAX][2], val[MMAX], root[NMAX];
int V = 0, N;
int node() {
  first[V][0] = first[V][0] = -1;
  return V++;
}
void initST() {
  root[0] = node();
  first[root[0]][0] = first[root[0]][1] = root[0];
}
void insert(int t, int v, int add) {
  if (add == 0) {
    root[t] = root[t - 1];
    return;
  }
  int actual = root[t] = node();
  int last = root[t - 1];
  int L = 1, R = N;
  while (true) {
    val[actual] = val[last] + add;
    if (L == R)
      break;
    else {
      int M = (L + R) / 2;
      if (v <= M) {
        first[actual][0] = node();
        first[actual][1] = first[last][1];
        R = M;
        actual = first[actual][0];
        last = first[last][0];
      } else {
        first[actual][0] = first[last][0];
        first[actual][1] = node();
        L = M + 1;
        actual = first[actual][1];
        last = first[last][1];
      }
    }
  }
}
int n;
int dfsCounter = 0;
void dfs(int current, int last, int L, int R, int v) {
  if (val[current] - val[last] == 0) return;
  if (R <= v) return;
  if (dfsCounter >= n) return;
  if (L == R) {
    dfsCounter++;
    join(v, L);
  } else {
    int M = (L + R) / 2;
    dfs(first[current][0], first[last][0], L, M, v);
    dfs(first[current][1], first[last][1], M + 1, R, v);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < int(n); i++) {
    scanf("%d %d", &LR[i].first, &LR[i].second);
  }
  sort(LR, LR + n);
  N = 2 * n;
  initST();
  init(N);
  int c = 1;
  for (int i = 0; i < int(n); i++) {
    while (c != LR[i].first) {
      insert(c, 1, 0);
      c++;
    }
    insert(LR[i].first, LR[i].second, 1);
    c++;
  }
  while (true) {
    insert(c, 1, 0);
    if (c >= N) break;
    c++;
  }
  for (int i = 0; i < int(n); i++) {
    dfs(root[LR[i].second - 1], root[LR[i].first], 1, N, LR[i].second);
  }
  if (dfsCounter != n - 1)
    printf("NO\n");
  else {
    bool possible = true;
    int current = getS(LR[0].second);
    for (int i = 0; i < int(n); i++) {
      if (getS(LR[i].second) != current) {
        possible = false;
        break;
      }
    }
    if (possible)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
