#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1LL << 60;
const int MAXN = 500001, INF = 1e9;
int parent[MAXN], ranking[MAXN];
void UF_precalc(int n) {
  for (int v = 1; v <= n; v++) parent[v] = v;
}
int find_set(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
bool union_sets(int u, int v) {
  u = find_set(u);
  v = find_set(v);
  if (u != v) {
    if (ranking[u] == ranking[v]) ranking[u]++;
    if (ranking[u] < ranking[v]) swap(u, v);
    parent[v] = u;
    return 1;
  }
  return 0;
}
struct seg {
  int b, e, ind;
};
bool cmp_b(seg X, seg Y) { return X.b < Y.b; }
struct cmp_e {
  bool operator()(const seg X, const seg Y) { return X.e < Y.e; }
};
int main() {
  int n;
  scanf("%d", &n);
  UF_precalc(n);
  vector<seg> segs(n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &segs[i].b, &segs[i].e);
    segs[i].ind = i;
  }
  sort(segs.begin(), segs.end(), cmp_b);
  int unions = 0;
  set<seg, cmp_e> open;
  for (int cs = 0; cs < n; cs++) {
    int b = segs[cs].b;
    int e = segs[cs].e;
    int ind = segs[cs].ind;
    while (!open.empty() && (*open.begin()).e < b) open.erase(open.begin());
    if (!open.empty())
      for (auto it = open.begin(); it != open.end() && (*it).e < e; it++)
        if (!union_sets(ind, (*it).ind)) {
          printf("NO\n");
          return 0;
        } else
          unions++;
    open.insert(segs[cs]);
  }
  if (unions == n - 1)
    printf("YES\n");
  else
    printf("NO\n");
}
