#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());
const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";
template <class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
  return out << "{" << a.first << ", " << a.second << "}";
}
template <class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
  return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
             << "}";
}
template <class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
  return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a)
             << ", " << get<3>(a) << "}";
}
template <class T>
inline ostream &operator<<(ostream &out, vector<T> &a) {
  out << "[";
  for (int i = 0; i < int(a.size()); ++i)
    out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
  return out;
}
void smain();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(12) << fixed;
  smain();
  return 0;
}
const int N = 1e6 + 10;
int lf[N], rf[N];
int anti_lf[N];
int anti_rf[N];
vector<int> t[N << 2];
vector<int> t2[N << 2];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    if (anti_rf[tl] != -1) t[v] = {lf[anti_rf[tl]]};
    return;
  }
  int tm = tl + tr >> 1;
  build(v << 1, tl, tm);
  build(v << 1 | 1, tm + 1, tr);
  t[v].resize(t[v << 1].size() + t[v << 1 | 1].size());
  merge(t[v << 1].begin(), t[v << 1].end(), t[v << 1 | 1].begin(),
        t[v << 1 | 1].end(), t[v].begin());
}
void build2(int v, int tl, int tr) {
  if (tl == tr) {
    if (anti_lf[tl] != -1) t2[v] = {-rf[anti_lf[tl]]};
    return;
  }
  int tm = tl + tr >> 1;
  build2(v << 1, tl, tm);
  build2(v << 1 | 1, tm + 1, tr);
  t2[v].resize(t2[v << 1].size() + t2[v << 1 | 1].size());
  merge(t2[v << 1].begin(), t2[v << 1].end(), t2[v << 1 | 1].begin(),
        t2[v << 1 | 1].end(), t2[v].begin());
  if (false) cerr << "t2[" << tl << ", " << tr << "] = " << t2[v] << endl;
}
int sz2;
int gath2[N];
void get2(int v, int tl, int tr, int l, int r, int lb) {
  if (l > r) return;
  if (tl == l && tr == r) {
    for (int j = 0; j < t2[v].size() && t2[v][j] < lb; ++j) {
      gath2[sz2++] = -t2[v][j];
      if (lb == -3) {
        if (false) cerr << ("-t2[v][j]") << " = " << (-t2[v][j]) << endl;
        ;
        if (false) cerr << ("tl") << " = " << (tl) << endl;
        ;
        if (false) cerr << ("tr") << " = " << (tr) << endl;
        ;
      }
    }
    return;
  }
  int tm = tl + tr >> 1;
  get2(v << 1, tl, tm, l, min(tm, r), lb);
  get2(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r, lb);
}
bool used[N];
int q[N + N];
int parent[N];
int gath[N];
int sz;
void get(int v, int tl, int tr, int l, int r, int lb) {
  if (l > r) return;
  if (tl == l && tr == r) {
    for (int j = 0; j < t[v].size() && t[v][j] < lb; ++j) {
      gath[sz++] = t[v][j];
    }
    return;
  }
  int tm = tl + tr >> 1;
  get(v << 1, tl, tm, l, min(tm, r), lb);
  get(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r, lb);
}
void smain() {
  fill(parent, parent + N, -1);
  fill(anti_rf, anti_rf + N, -1);
  fill(anti_lf, anti_lf + N, -1);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> lf[i] >> rf[i];
    anti_lf[lf[i]] = i;
    anti_rf[rf[i]] = i;
  }
  build(1, 1, 2 * n);
  build2(1, 1, 2 * n);
  int ql, qr;
  ql = qr = 0;
  used[0] = true;
  q[qr++] = 0;
  while (ql < qr) {
    int v = q[ql++];
    sz = 0;
    get(1, 1, 2 * n, lf[v], rf[v], lf[v]);
    sz2 = 0;
    get2(1, 1, 2 * n, lf[v], rf[v], -rf[v]);
    for (int i = 0; i < int(sz); ++i) {
      int u = anti_lf[gath[i]];
      if (u != parent[v]) {
        if (used[u]) {
          cout << "NO";
          return;
        }
        q[qr++] = u;
        parent[u] = v;
        used[u] = true;
      }
    }
    for (int i = 0; i < int(sz2); ++i) {
      int u = anti_rf[gath2[i]];
      if (u != parent[v]) {
        if (used[u]) {
          cout << "NO";
          return;
        }
        q[qr++] = u;
        parent[u] = v;
        used[u] = true;
      }
    }
  }
  if (accumulate(used, used + n, 0) == n) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
