#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > allr;
int par[500001];
int h[500001];
int n;
bool pos = true;
int mergecnt = 0;
int find(int node) {
  if (node == par[node]) return node;
  par[node] = find(par[node]);
}
bool comb(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    mergecnt++;
    if (h[a] > h[b]) {
      par[b] = a;
    } else if (h[a] < h[b]) {
      par[a] = b;
    } else {
      par[a] = b;
      h[b]++;
    }
    return true;
  }
  return false;
}
struct segtree {
  segtree *left, *right;
  int l, r;
  vector<pair<int, int> > ranges;
  segtree(int l, int r) : l(l), r(r) {
    if (l == r) {
      ranges.emplace_back(allr[l].second, r);
    } else {
      int m = (l + r) >> 1;
      left = new segtree(l, m);
      right = new segtree(m + 1, r);
      int sl = 0;
      int sr = 0;
      while (sl < left->ranges.size() && sr < right->ranges.size()) {
        if (left->ranges[sl].first < right->ranges[sr].first)
          ranges.emplace_back(left->ranges[sl].first, left->ranges[sl].second),
              sl++;
        else
          ranges.emplace_back(right->ranges[sr].first,
                              right->ranges[sr].second),
              sr++;
      }
      while (sl < left->ranges.size())
        ranges.emplace_back(left->ranges[sl].first, left->ranges[sl].second),
            sl++;
      while (sr < right->ranges.size())
        ranges.emplace_back(right->ranges[sr].first, right->ranges[sr].second),
            sr++;
      sort(ranges.begin(), ranges.end());
    }
  }
  void merge(int mergenode, int st, int en) {
    if (!pos) return;
    if (st <= l && r <= en) {
      int s = 0;
      int e = ranges.size() - 1;
      int reach = -1;
      while (s <= e) {
        int m = (s + e) >> 1;
        if (allr[mergenode].second < ranges[m].first) {
          e = m - 1;
          reach = m;
        } else
          s = m + 1;
      }
      if (reach != -1) {
        for (int i = reach; i < ranges.size(); i++) {
          pos = pos & comb(mergenode, ranges[i].second);
          if (!pos) return;
        }
      }
    } else if (l > en || r < st) {
      return;
    } else {
      left->merge(mergenode, st, en);
      right->merge(mergenode, st, en);
    }
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    allr.emplace_back(a, b);
  }
  for (int i = 0; i < n; i++) par[i] = i;
  sort(allr.begin(), allr.end());
  segtree *tree = new segtree(0, n - 1);
  for (int i = 0; i < n; i++) {
    int s = i + 1;
    int e = n - 1;
    int furthest = i;
    while (s <= e) {
      int m = (s + e) >> 1;
      if (allr[m].first < allr[i].second) {
        s = m + 1;
        furthest = m;
      } else
        e = m - 1;
    }
    if (furthest != i) {
      tree->merge(i, i + 1, furthest);
    }
  }
  cout << (pos && mergecnt == n - 1 ? "YES" : "NO") << '\n';
}
