#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  int s = 0, c = getchar();
  x = 0;
  while (isspace(c)) c = getchar();
  if (c == 45) s = 1, c = getchar();
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (s) x = -x;
}
template <typename T>
void write(T x, char c = ' ') {
  int b[40], l = 0;
  if (x < 0) putchar(45), x = -x;
  while (x > 0) b[l++] = x % 10, x /= 10;
  if (!l) putchar(48);
  while (l) putchar(b[--l] | 48);
  putchar(c);
}
const int N = 5e5 + 8;
set<pair<int, int>> qwq;
vector<pair<int, int>> line;
vector<int> edge[N];
vector<bool> sign;
int n;
void DFS(int x) {
  sign[x] = true;
  for (auto i : edge[x])
    if (!sign[i]) DFS(i);
}
bool Solve(void) {
  read(n);
  for (int u, v, i = 1; i <= n; ++i) {
    read(u);
    read(v);
    line.push_back(make_pair(u, v));
  }
  sort(line.begin(), line.end());
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    auto it = qwq.lower_bound(make_pair(line[i].first, 0));
    while (it != qwq.end() && (*it).first <= line[i].second) {
      ++cnt;
      if (cnt >= n) return false;
      edge[i].push_back((*it).second);
      edge[(*it).second].push_back(i);
      ++it;
    }
    qwq.insert(make_pair(line[i].second, i));
  }
  if (cnt < n - 1) return false;
  sign.resize(n);
  DFS(0);
  for (auto i : sign)
    if (i == false) return false;
  return true;
}
int main(void) {
  if (Solve())
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
