#include <bits/stdc++.h>
using namespace std;
int sai[500010];
int check[500010];
pair<int, int> bang[500010];
int n;
vector<pair<int, int> > arr;
void initset(int N) {
  for (int i = 1; i <= N; i++) {
    sai[i] = 1;
    check[i] = i;
  }
}
int findset(int x) {
  if (check[x] == x)
    return x;
  else
    return check[x] = findset(check[x]);
}
void unionset(int x, int y) {
  x = findset(x);
  y = findset(y);
  if (x != y) {
    if (sai[x] < sai[y]) swap(x, y);
    check[y] = x;
    sai[x] += sai[y];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> bang[i].first >> bang[i].second;
  initset(n);
  for (int i = 1; i <= n; i++) {
    arr.push_back(pair<int, int>(bang[i].first, i));
    arr.push_back(pair<int, int>(bang[i].second, i));
  }
  sort(arr.begin(), arr.end());
  int dem = 0;
  set<pair<int, int> > s;
  for (auto i : arr) {
    if (dem >= n) {
      cout << "NO";
      return 0;
    }
    if (s.count(i) == 1)
      s.erase(i);
    else {
      int idx = bang[i.second].second;
      for (auto j : s) {
        if (j.first > idx) break;
        unionset(i.second, j.second);
        ++dem;
        if (dem >= n) {
          cout << "NO";
          return 0;
        }
      }
      s.insert(pair<int, int>(bang[i.second].second, i.second));
    }
  }
  for (int i = 1; i <= n; i++) {
    if (check[i] == i) {
      if (sai[i] == n)
        cout << "YES";
      else
        cout << "NO";
      return 0;
    }
  }
}
