#include <bits/stdc++.h>
using namespace std;
vector<int> g[500000];
bool visited[500000];
int n;
unordered_map<int, int> m, p;
vector<pair<int, int> > v;
void check(int u) {
  visited[u] = true;
  for (auto v : g[u]) {
    if (!visited[v]) check(v);
  }
}
int main() {
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    m[a] = b;
    v.push_back({a, 0});
    v.push_back({b, 1});
    p[a] = i;
    p[b] = i;
  }
  sort(v.begin(), v.end());
  int count = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i].second == 0) {
      for (auto ele : s) {
        if (ele < m[v[i].first]) {
          count++;
          g[p[v[i].first]].push_back(p[ele]);
          g[p[ele]].push_back(p[v[i].first]);
        } else
          break;
      }
      if (count > n - 1) {
        break;
      }
      s.insert(m[v[i].first]);
    } else {
      s.erase(v[i].first);
    }
  }
  if (count == n - 1) {
    check(0);
    int i;
    for (i = 0; i < n; i++) {
      if (!visited[i]) break;
    }
    if (i == n)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  } else
    cout << "NO" << endl;
}
