#include <bits/stdc++.h>
using namespace std;
const int MX = 1e6 + 4;
const int LIM = 6e5 + 3;
std::vector<int> adj[LIM + 3];
pair<int, int> a[LIM + 3];
bool vis[LIM + 3];
void dfs(int u) {
  vis[u] = 1;
  for (auto v : adj[u])
    if (!vis[v]) dfs(v);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    a[i] = make_pair(x, y);
  }
  sort(a, a + n);
  set<pair<pair<int, int>, int> > cur;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x = a[i].first, y = a[i].second;
    vector<pair<pair<int, int>, int> > del;
    for (auto el : cur) {
      if (el.first.first < x)
        del.push_back(el);
      else if (el.first.first > y)
        break;
      else {
        adj[i].push_back(el.second);
        adj[el.second].push_back(i);
        cnt++;
      }
    }
    if (cnt >= n) break;
    for (auto el : del) cur.erase(el);
    cur.insert(make_pair(make_pair(y, x), i));
  }
  if (cnt != n - 1)
    puts("NO");
  else {
    dfs(0);
    bool ans = true;
    for (int i = 0; i < n; i++)
      if (!vis[i]) ans = 0;
    if (ans)
      puts("YES");
    else
      puts("NO");
  }
}
