#include <bits/stdc++.h>
using namespace std;
inline int ReadInt() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int x = c - '0';
  while (c = getchar(), c >= '0' && c <= '9') x = x * 10 + c - '0';
  return x;
}
const int N = 5e5 + 2;
int n, b[2 * N], e = 0, visit[N], c[N];
pair<int, int> a[2 * N], IT;
vector<int> adj[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    b[a[i].first] = i;
    b[a[i].second] = -i;
    c[i] = a[i].first;
  }
  a[0] = {0, 2 * n + 1};
  int cur = 0, u, v, t1, t2;
  for (int i = 1; i <= 2 * n; i++) {
    if (b[i] > 0) {
      a[cur].second = i;
      a[i].first = cur;
      cur = i;
    } else {
      v = cur;
      u = abs(b[i]);
      for (; v > c[u]; v = a[v].first) {
        if (b[v] != u) {
          adj[u].push_back(b[v]);
          adj[b[v]].push_back(u);
          e++;
          if (e >= n) break;
        }
      }
      u = c[u];
      t1 = a[u].first;
      t2 = a[u].second;
      a[t1].second = t2;
      a[t2].first = t1;
      if (cur == u) cur = a[u].first;
    }
    if (e >= n) break;
  }
  if (e >= n)
    cout << "NO" << '\n';
  else {
    queue<int> qu;
    qu.push(1);
    visit[1] = 1;
    while (!qu.empty()) {
      u = qu.front();
      qu.pop();
      for (int i = 0; i < adj[u].size(); i++) {
        v = adj[u][i];
        if (visit[v]) continue;
        visit[v] = 1;
        qu.push(v);
      }
    }
    int ok = 1;
    for (int i = 1; i <= n; i++) {
      if (!visit[i]) ok = 0;
    }
    if (ok)
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
}
