#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
int cnt, a, b, vcnt, vadd;
vector<int> v[maxn];
bool checked[maxn] = {0};
int neigh[maxn], ednum[maxn], prep[maxn], aft[maxn];
bool ans = true;
bool dfs_tree(int x, int from) {
  if (checked[x]) return false;
  checked[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != from) {
      if (!dfs_tree(v[x][i], x)) return false;
    }
  }
  return true;
}
int main() {
  scanf("%d", &cnt);
  for (int i = 1; i <= 2 * cnt + 1; i++) {
    prep[i] = i - 1;
  }
  for (int i = 0; i <= 2 * cnt; i++) {
    aft[i] = i + 1;
  }
  for (int i = 1; i <= cnt; i++) {
    scanf("%d %d", &a, &b);
    neigh[a] = b;
    neigh[b] = a;
    ednum[a] = i;
    ednum[b] = i;
  }
  vcnt = 0;
  for (int i = 1; i <= 2 * cnt; i++) {
    if (neigh[i] > i) {
    } else {
      int idx = neigh[i];
      while (aft[idx] < i) {
        idx = aft[idx];
        a = ednum[idx];
        b = ednum[i];
        v[a].push_back(b);
        v[b].push_back(a);
        vcnt++;
        if (vcnt > cnt - 1) {
          ans = false;
          break;
        }
      }
      idx = neigh[i];
      aft[prep[idx]] = aft[idx];
      prep[aft[idx]] = prep[idx];
      aft[prep[i]] = aft[i];
      prep[aft[i]] = prep[i];
    }
    if (!ans) break;
  }
  if (vcnt < cnt - 1) ans = false;
  for (int i = 1; i <= cnt - 1; i++)
    if (v[i].size() == 0) ans = false;
  if (ans) ans = dfs_tree(1, 0);
  for (int i = 1; i <= cnt - 1; i++)
    if (!checked[i]) ans = false;
  if (ans) {
    printf("YES\n");
  } else
    printf("NO\n");
}
