#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 500005;
int p[maxn];
pair<int, int> a[maxn];
int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); }
bool uni(int x, int y) {
  x = find(x), y = find(y);
  if (x == y)
    return 1;
  else
    return p[y] = x, 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].first, &a[i].second), p[i] = i;
  sort(a + 1, a + 1 + n);
  int ans = 0;
  map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    while (mp.size() && mp.begin()->first < a[i].first) mp.erase(mp.begin());
    for (auto it = mp.begin(); it != mp.end(); it++) {
      if (it->first > a[i].second) break;
      if (uni(it->second, i))
        return printf("NO\n"), 0;
      else
        ans++;
    }
    mp[a[i].second] = i;
  }
  printf("%s\n", ans == n - 1 ? "YES" : "NO");
  return 0;
}
