#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using ld = long double;
mt19937 mtrd(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1000000007;
const int mod2 = 998244353;
const ld PI = acos(-1);
long long qpow(long long x, long long powcnt, long long tomod) {
  long long res = 1;
  for (; powcnt; powcnt >>= 1, x = (x * x) % tomod)
    if (1 & powcnt) res = (res * x) % tomod;
  return (res % tomod);
}
long long inv(long long x) { return qpow(x, mod - 2, mod); }
const long long N = 5e5 + 10;
struct Disjoint_Set {
  long long p[N];
  long long sz[N];
  void init() {
    memset((p), (-1), sizeof((p)));
    for (long long i = 0; i < N; i++) sz[i] = 1;
  }
  long long fp(long long x) { return p[x] == -1 ? x : p[x] = fp(p[x]); }
  bool U(long long x, long long y) {
    x = fp(x);
    y = fp(y);
    if (x == y) return false;
    if (sz[x] > sz[y]) swap(x, y);
    p[x] = y;
    sz[y] += sz[x];
    return true;
  }
} dsu;
long long n;
long long L[N];
void solve() {
  cin >> n;
  dsu.init();
  vector<long long> a(2 * n);
  for (long long i = 1; i <= n; i++) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    a[l] = a[r] = i;
    L[i] = l;
  }
  set<pll> s;
  long long cnt = 0;
  for (auto i : a) {
    if (cnt >= n) break;
    if (s.count(make_pair(L[i], i))) {
      s.erase(make_pair(L[i], i));
      auto it = s.lower_bound(make_pair(L[i], i));
      for (; it != s.end(); it++) {
        cnt++;
        if (!dsu.U(it->second, i)) {
          cout << "NO\n";
          return;
        }
        if (cnt >= n) break;
      }
    } else
      s.insert(make_pair(L[i], i));
  }
  cout << (cnt == n - 1 ? "YES\n" : "NO\n");
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) solve();
}
