#include <bits/stdc++.h>
using namespace std;
const int N = 500000;
int p[N], siz[N];
vector<int> tr[8 * N];
int d = 1;
int dsuFind(int v) {
  if (p[v] == v) {
    return p[v];
  }
  return p[v] = dsuFind(p[v]);
}
int dsuUnion(int v, int u) {
  v = dsuFind(v);
  u = dsuFind(u);
  if (u == v) {
    cout << "NO";
    exit(0);
  }
  if (siz[v] > siz[u]) {
    swap(u, v);
  }
  siz[u] += siz[v];
  p[v] = u;
}
void add(int v, int ind) {
  while (v >= 1) {
    tr[v].push_back(ind);
    v /= 2;
  }
}
void go(int v, int need_l, int need_r, int l, int r, int now) {
  if (need_l > need_r) {
    return;
  }
  if (l == need_l && r == need_r) {
    for (int i = 0; i < tr[v].size(); ++i) {
      dsuUnion(now, tr[v][i]);
    }
    return;
  }
  go(2 * v, need_l, min(need_r, (l + r) / 2), l, (l + r) / 2, now);
  go(2 * v + 1, max(need_l, (l + r) / 2 + 1), need_r, (l + r) / 2 + 1, r, now);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  while (d < 2 * n) {
    d *= 2;
  }
  vector<pair<pair<int, int>, int> > a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first.first >> a[i].first.second;
    a[i].first.first--;
    a[i].first.second--;
    a[i].second = i;
    p[i] = i;
    siz[i] = 1;
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    go(1, a[i].first.first, a[i].first.second, 0, d - 1, a[i].second);
    add(a[i].first.second + d, a[i].second);
  }
  for (int i = 0; i < n; ++i) {
    if (siz[i] == n) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
