#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 2;
int n, cnt, visit[N];
vector<int> graph[N];
set<pair<int, int> > Set;
vector<pair<int, int> > p(N), border;
void dfs(int v, int p) {
  visit[v] = 1;
  for (int u : graph[v]) {
    if (!visit[u] && u != p) dfs(u, v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].first >> p[i].second;
    border.push_back(pair<int, int>(p[i].first, i));
    border.push_back(pair<int, int>(p[i].second, i));
  }
  sort(border.begin(), border.end());
  for (auto v : border) {
    if (cnt >= n) break;
    if (Set.count(v)) {
      Set.erase(v);
    } else {
      int i = v.second, r = p[i].second;
      for (auto x : Set) {
        if (x.first >= r)
          break;
        else {
          int j = x.second;
          graph[i].push_back(j);
          graph[j].push_back(i);
          cnt++;
          if (cnt >= n) break;
        }
      }
      Set.insert(pair<int, int>(p[i].second, i));
    }
  }
  dfs(1, 0);
  if (cnt == n - 1 && count(visit + 1, visit + 1 + n, 1) == n)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
