#include <bits/stdc++.h>
using namespace std;
struct msp {
  int l, r, num;
  bool operator<(const msp& y) const { return r < y.r; }
} a[500010];
bool cmp(const msp& x, const msp& y) { return x.l < y.l; }
const int maxn = 1000010;
struct BIT {
  int data[maxn], n;
  void init(const int& l) { n = l; }
  inline int lowbit(const int& x) { return x & -x; }
  void plus(int x, const int& dta) {
    while (x <= n) {
      data[x] += dta;
      x += lowbit(x);
    }
  }
  int cnt(int x) {
    int sum = 0;
    while (x) {
      sum += data[x];
      x ^= lowbit(x);
    }
    return sum;
  }
  inline int sum(const int& l, const int& r) { return cnt(r) - cnt(l - 1); }
};
int fa[510000];
int father(int x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = father(fa[x]);
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i += 1) {
    cin >> a[i].l >> a[i].r;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i += 1) {
    a[i].num = fa[i] = i;
  }
  int now = 1;
  int s = 0, flag = 0;
  set<msp> st;
  for (int i = 1; i <= n; i += 1) {
    while (st.size() && st.begin()->r < a[i].l) st.erase(st.begin());
    for (auto& k : st) {
      if (k.r < a[i].r)
        ++s;
      else
        break;
      if (s >= n) {
        flag = 1;
        break;
      }
      fa[father(k.num)] = father(i);
    }
    st.insert(a[i]);
  }
  int h = father(1);
  for (int i = 1; i <= n; i += 1) {
    if (father(i) != h) {
      flag = 1;
      break;
    }
  }
  cout << ((!flag && s == n - 1) ? "YES" : "NO") << '\n';
  return 0;
}
