#include <bits/stdc++.h>
using namespace std;
int n, dp[1000005];
pair<int, int> pai[1000005];
set<int> s;
int f[1000005], pre[1000005], a[1000005], tot;
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
int val[1000005 << 2];
void down(int p) {
  if (!val[p]) return;
  val[p << 1] += val[p];
  val[p << 1 | 1] += val[p];
  val[p] = 0;
}
void update(int p, int x, int y, int v, int l, int r) {
  if (x <= l && y >= r) {
    val[p] += v;
    return;
  }
  down(p);
  int mid = l + r >> 1;
  if (x <= mid) update(p << 1, x, y, v, l, mid);
  if (y > mid) update(p << 1 | 1, x, y, v, mid + 1, r);
}
int query(int p, int l, int r, int pos) {
  if (l == r) return val[p];
  down(p);
  int mid = l + r >> 1;
  if (pos <= mid)
    return query(p << 1, l, mid, pos);
  else
    return query(p << 1 | 1, mid + 1, r, pos);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &pai[i].first, &pai[i].second);
  sort(pai + 1, pai + n + 1);
  for (int i = 1; i <= n; i++) a[pai[i].second] = i, f[i] = i;
  for (int i = 1, fu, fv; i <= n; i++) {
    set<int>::iterator it = s.lower_bound(pai[i].second);
    if (i == 1 || it == s.begin()) {
      dp[pai[i].second] = -1;
      s.insert(pai[i].second);
    } else {
      it--, dp[pai[i].second] = *it;
      if (pai[i].first <= dp[*it]) {
        puts("NO");
        return 0;
      }
      s.insert(pai[i].second);
      fu = find(i), fv = find(a[*it]);
      if (fu != fv && pai[i].first <= *it) f[fu] = fv;
    }
    if (i < n) {
      int l = i + 1, r = n, mid, ans = 0;
      while (l <= r) {
        mid = l + r >> 1;
        if (pai[mid].second > pai[i].second)
          ans = mid, r = mid - 1;
        else
          l = mid + 1;
      }
      if (ans) {
        fu = find(i), fv = find(ans);
        if (fu != fv && pai[i].second >= pai[ans].first) f[fu] = fv;
      }
    }
    tot += query(1, 1, 1000005 - 5, pai[i].first) -
           query(1, 1, 1000005 - 5, pai[i].second);
    update(1, pai[i].first, pai[i].second, 1, 1, 1000005 - 5);
  }
  if (tot != n - 1) {
    puts("NO");
    return 0;
  }
  tot = 0;
  for (int i = 1; i <= n; i++)
    if (find(i) == i) tot++;
  if (tot == 1)
    puts("YES");
  else
    puts("NO");
}
