#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 7;
int pre[maxn << 1], l[maxn << 1], r[maxn << 1];
int n;
int find(int x) { return x == pre[x] ? x : pre[x] = find(pre[x]); }
bool merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return false;
  pre[fx] = fy;
  return true;
}
bool rua() {
  set<int> S;
  for (int i = 1; i <= n + n; i++) pre[i] = i;
  for (int i = 1; i <= n + n; i++) {
    if (r[i]) {
      S.insert(r[i]);
      set<int>::iterator it = S.lower_bound(i);
      while (it != S.end() && (*it) < r[i]) {
        if (!merge(l[*it], i)) return false;
        it++;
      }
    }
  }
  int rt = find(1);
  for (int i = 1; i <= n + n; i++)
    if (r[i] && find(i) != rt) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    l[y] = x;
    r[x] = y;
  }
  printf(rua() ? "YES\n" : "NO\n");
  return 0;
}
