#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
struct node {
  int l, r;
  bool operator<(const node &a) const { return l < a.l; }
} line[N];
set<int> s;
vector<int> id;
int fa[N];
int find(int x) {
  if (x == fa[x]) {
    return fa[x];
  } else {
    return fa[x] = find(fa[x]);
  }
}
map<int, int> m;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> line[i].l >> line[i].r;
    id.push_back(line[i].l);
    id.push_back(line[i].r);
  }
  sort(id.begin(), id.end());
  id.erase(unique(id.begin(), id.end()), id.end());
  for (int i = 1; i <= n; i++) {
    line[i].l = lower_bound(id.begin(), id.end(), line[i].l) - id.begin();
    line[i].r = lower_bound(id.begin(), id.end(), line[i].r) - id.begin();
  }
  sort(line + 1, line + 1 + n);
  for (int i = 1; i <= n; i++) {
    m[line[i].r] = i;
  }
  int cnt = 0;
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    for (auto it = s.upper_bound(line[i].l); it != s.end() && *it < line[i].r;
         it++) {
      int fx = find(i), fy = find(m[*it]);
      cnt++;
      if (fx == fy || cnt >= n) {
        flag = false;
        break;
      }
      fa[fx] = fy;
    }
    s.insert(line[i].r);
  }
  if (flag) {
    int root = find(1);
    for (int i = 2; i <= n; i++) {
      if (find(i) != root) {
        cout << "NO" << endl;
        return 0;
      }
    }
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
