#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
int v[500003];
int ar[4 * 500003], Min[4 * 500003];
int par[500003], lev[500003];
void makeset(int n) {
  fill(par, par + n, -1);
  fill(lev, lev + n, 0);
  return;
}
int findset(int x) {
  int y = x;
  while (par[y] >= 0) y = par[y];
  if (x != y) par[x] = y;
  return y;
}
int cycle;
void combine(int a, int b) {
  a = findset(a);
  b = findset(b);
  if (a == b) cycle = 1;
  if (a != b) {
    if (lev[a] < lev[b])
      par[a] = b;
    else if (lev[a] > lev[b])
      par[b] = a;
    else
      lev[b]++, par[a] = b;
  }
  return;
}
void pull(int p) {
  ar[p] = max(ar[2 * p], ar[2 * p + 1]);
  Min[p] = min(Min[2 * p], Min[2 * p + 1]);
}
void build(int l, int h, int p) {
  if (l == h) {
    ar[p] = v[l];
    Min[p] = v[l];
    return;
  }
  int m = ((l + h) >> 1);
  build(l, m, 2 * p);
  build(m + 1, h, 2 * p + 1);
  pull(p);
}
void query(int a, int b, int r, int k, int l, int h, int p) {
  if (ar[p] < r)
    return;
  else if (a > h || b < l)
    return;
  if (l == h) {
    combine(k, l);
    return;
  }
  if (a <= l && b >= h && Min[p] > r) {
    int i;
    for (i = l; i < h + 1; i++) combine(k, i);
    return;
  }
  int m = ((l + h) >> 1);
  query(a, b, r, k, l, m, 2 * p);
  query(a, b, r, k, m + 1, h, 2 * p + 1);
  return;
}
int main() {
  int n, i, l, r, a, j;
  scanf("%d", &n);
  vector<pair<int, int> > vp(n);
  for (i = 0; i < n; i++) scanf("%d%d", &l, &r), vp[i] = {l, r};
  sort(vp.begin(), vp.end());
  makeset(n);
  for (i = 0; i < n; i++) v[i] = vp[i].second;
  build(0, n - 1, 1);
  pair<int, int> temp;
  for (i = 0; i < n; i++) {
    if (!cycle) {
      tie(l, r) = vp[i];
      temp = {r, 0};
      j = lower_bound(vp.begin(), vp.end(), temp) - vp.begin();
      if (i + 1 <= j - 1) query(i + 1, j - 1, r, i, 0, n - 1, 1);
    }
  }
  a = 0;
  for (i = 0; i < n; i++)
    if (par[i] < 0) a++;
  if (!cycle && a == 1)
    printf("YES\n");
  else
    printf("NO\n");
}
