#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int sum[maxn * 19], ls[maxn * 19], rs[maxn * 19], rt[maxn];
int li[maxn], ri[maxn], has[maxn], pre[maxn], pi[maxn], cnt[maxn];
int n, cur, tot;
int fin(int x) { return x == pre[x] ? x : pre[x] = fin(pre[x]); }
void unite(int x, int y) { pre[fin(x)] = fin(y); }
void update(int l, int r, int &rt, int pre, int pos, int val) {
  rt = ++tot;
  ls[rt] = ls[pre], rs[rt] = rs[pre], sum[rt] = sum[pre] + val;
  if (l == r) return;
  int mid = (l + r >> 1);
  if (pos <= mid)
    update(l, mid, ls[rt], ls[pre], pos, val);
  else
    update(mid + 1, r, rs[rt], rs[pre], pos, val);
}
int query(int l, int r, int rt, int pre, int L, int R) {
  if (l >= L && r <= R) return sum[rt] - sum[pre];
  int mid = (l + r >> 1), ret = 0;
  if (L <= mid) ret += query(l, mid, ls[rt], ls[pre], L, R);
  if (R > mid) ret += query(mid + 1, r, rs[rt], rs[pre], L, R);
  return ret;
}
void dfs(int l, int r, int rt, int pre) {
  if (sum[rt] - sum[pre] == 0) return;
  if (l == r) {
    unite(cur, has[r]);
    return;
  }
  int mid = (l + r >> 1);
  dfs(l, mid, ls[rt], ls[pre]);
  dfs(mid + 1, r, rs[rt], rs[pre]);
}
void Query(int l, int r, int rt, int pre, int L, int R) {
  if (sum[rt] - sum[pre] == 0) return;
  if (l >= L && r <= R) {
    dfs(l, r, rt, pre);
    return;
  }
  int mid = (l + r >> 1);
  if (L <= mid) Query(l, mid, ls[rt], ls[pre], L, R);
  if (R > mid) Query(mid + 1, r, rs[rt], rs[pre], L, R);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &li[i], &ri[i]);
    pi[li[i]] = ri[i], has[ri[i]] = i;
  }
  int lim = n << 1;
  for (int i = 1; i <= lim; ++i) {
    rt[i] = rt[i - 1];
    if (!pi[i]) continue;
    update(1, lim, rt[i], rt[i - 1], pi[i], 1);
  }
  int ret = 0;
  for (int i = 1; i <= n; ++i) {
    int l = li[i] + 1, r = ri[i] - 1;
    if (l > r || ret > n - 1) continue;
    cnt[i] = query(1, lim, rt[r], rt[l - 1], min(ri[i] + 1, lim), lim);
    ret += cnt[i];
  }
  if (ret != n - 1)
    printf("NO\n");
  else {
    for (int i = 1; i <= n; ++i) pre[i] = i;
    for (int i = 1; i <= n; ++i) {
      int l = li[i] + 1, r = ri[i] - 1;
      if (l > r) continue;
      cur = i;
      Query(1, lim, rt[r], rt[l - 1], min(ri[i] + 1, lim), lim);
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) cnt += pre[i] == i;
    printf("%s\n", cnt == 1 ? "YES" : "NO");
  }
  return 0;
}
