#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 100;
const long long M = 10;
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
const long long P = 1336;
const long double eps = 0.000000001;
const long long inf = 1e9 + 7;
mt19937 gen(time(0));
vector<long long> g[N];
struct segtree {
  vector<long long> t, cur;
  long long st;
  segtree(long long n) {
    long long p = 0;
    while ((1ll << p) < n) ++p;
    st = (1ll << p);
    t.resize(2 * st + 2);
    for (long long i = 0; i <= 2 * st; i++) {
      t[i] = 0;
    }
    cur.assign(2 * st, 0);
  }
  void upd(long long v, long long x) {
    v += st;
    t[v] = 1;
    cur[v] = x;
    v /= 2;
    while (v) {
      t[v] = t[v * 2] + t[v * 2 + 1];
      v /= 2;
    }
  }
  long long sum(long long v, long long cl, long long cr, long long l,
                long long r) {
    if (cl > r || cr < l) return 0;
    if (l <= cl && cr <= r) {
      return t[v];
    }
    long long mid = (cl + cr) / 2;
    return sum(v * 2, cl, mid, l, r) + sum(v * 2 + 1, mid + 1, cr, l, r);
  }
  void merge(long long x, long long v, long long cl, long long cr, long long l,
             long long r) {
    if (cl > r || cr < l) return;
    if (t[v] == 0) return;
    if (cl == cr) {
      g[x].push_back(cur[v]);
      g[cur[v]].push_back(x);
      return;
    }
    long long mid = (cl + cr) / 2;
    merge(x, v * 2, cl, mid, l, r);
    merge(x, v * 2 + 1, mid + 1, cr, l, r);
  }
};
long long kek = 0;
vector<long long> used;
void dfs(long long v, long long p) {
  used[v] = 1;
  for (auto to : g[v]) {
    if (used[to]) continue;
    dfs(to, v);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  long long n;
  cin >> n;
  segtree t(2 * n + 2);
  used.assign(n, 0);
  vector<pair<pair<long long, long long>, long long> > a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i].first.first >> a[i].first.second;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  long long cnt = 0;
  long long it = 0;
  for (auto to : a) {
    ++it;
    long long x = to.first.first, y = to.first.second, val = to.second;
    --x, --y;
    long long res = t.sum(1, 0, t.st - 1, x + 1, y - 1);
    cnt += res;
    if (cnt > n - 1) {
      break;
    }
    t.merge(val, 1, 0, t.st - 1, x + 1, y - 1);
    t.upd(y, val);
  }
  if (cnt != n - 1) {
    cout << "NO";
    return 0;
  }
  dfs(0, 0);
  for (long long i = 0; i < n; ++i) {
    if (!used[i]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}
