#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 4, oo = 1e9 + 7;
int n, maxVal;
pair<int, int> a[N];
struct Interval_Tree {
  int node[4 * N], Trace[4 * N];
  void clear() {
    for (int i = 0; i < (int)4 * N; ++i) node[i] = Trace[i] = 0;
  }
  void update(int i, int l, int r, int x, int y, int val, int id) {
    if (l > y || x > r) return;
    if (x <= l && r <= y) {
      node[i] = val;
      Trace[i] = id;
      return;
    }
    int mid = (l + r) / 2;
    update(2 * i, l, mid, x, y, val, id);
    update(2 * i + 1, mid + 1, r, x, y, val, id);
    node[i] = max(node[2 * i], node[2 * i + 1]);
    Trace[i] =
        (node[2 * i] <= node[2 * i + 1]) ? Trace[2 * i + 1] : Trace[2 * i];
  }
  pair<int, int> get(int i, int l, int r, int x, int y) {
    if (l > y || x > r) return pair<int, int>(-oo, -oo);
    if (x <= l && r <= y) return pair<int, int>(node[i], Trace[i]);
    int mid = (l + r) / 2;
    pair<int, int> tmp1 = get(2 * i, l, mid, x, y),
                   tmp2 = get(2 * i + 1, mid + 1, r, x, y);
    return max(tmp1, tmp2);
  }
  void Add(int i, int l, int r, int x, int y, int val) {
    if (l > y || x > r) return;
    if (x <= l && r <= y) {
      node[i] += val;
      return;
    }
    int mid = (l + r) / 2;
    Add(2 * i, l, mid, x, y, val);
    Add(2 * i + 1, mid + 1, r, x, y, val);
    node[i] = node[2 * i] + node[2 * i + 1];
  }
  int getSum(int i, int l, int r, int x, int y) {
    if (l > y || x > r) return 0;
    if (x <= l && r <= y) return node[i];
    int mid = (l + r) / 2;
    int tmp1 = getSum(2 * i, l, mid, x, y),
        tmp2 = getSum(2 * i + 1, mid + 1, r, x, y);
    return tmp1 + tmp2;
  }
} IT_max, IT_min;
queue<int> Q;
bool vis[N];
void Check_connected() {
  IT_max.clear();
  for (int i = 1; i <= (int)maxVal; ++i)
    IT_min.update(1, 1, maxVal, i, i, -oo, -1);
  for (int i = 2; i <= (int)n; ++i) {
    IT_max.update(1, 1, maxVal, a[i].first, a[i].first, a[i].second, i);
    IT_min.update(1, 1, maxVal, a[i].second, a[i].second, -a[i].first, i);
  }
  Q.push(1);
  while (Q.size()) {
    int u = Q.front();
    vis[u] = true;
    Q.pop();
    int l = a[u].first, r = a[u].second;
    while (true) {
      pair<int, int> foo = IT_max.get(1, 1, maxVal, l, r);
      if (foo.first <= r) break;
      int v = foo.second;
      Q.push(v);
      IT_max.update(1, 1, maxVal, a[v].first, a[v].first, -oo, -1);
      IT_min.update(1, 1, maxVal, a[v].second, a[v].second, -oo, -1);
    }
    while (true) {
      pair<int, int> foo = IT_min.get(1, 1, maxVal, l, r);
      if (-foo.first >= l) break;
      int v = foo.second;
      Q.push(v);
      IT_max.update(1, 1, maxVal, a[v].first, a[v].first, -oo, -1);
      IT_min.update(1, 1, maxVal, a[v].second, a[v].second, -oo, -1);
    }
  }
  for (int i = 1; i <= (int)n; ++i)
    if (!vis[i]) {
      cout << "NO\n";
      exit(0);
    }
}
void Check_numEdge() {
  sort(a + 1, a + n + 1);
  int numEdge = 0;
  for (int l = 1; l <= (int)n; ++l) {
    int r = l;
    while (r <= n && a[r].first == a[l].first) ++r;
    --r;
    for (int i = l; i <= (int)r; ++i) {
      int num = IT_max.getSum(1, 1, maxVal, a[i].first, a[i].second);
      numEdge += num;
      if (numEdge > n - 1) {
        cout << "NO\n";
        exit(0);
      }
    }
    for (int i = l; i <= (int)r; ++i)
      IT_max.Add(1, 1, maxVal, a[i].second, a[i].second, 1);
    l = r;
  }
  if (numEdge != n - 1) {
    cout << "NO\n";
    exit(0);
  }
};
void sol() {
  Check_numEdge();
  Check_connected();
  cout << "YES\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cin >> n;
  for (int i = 1; i <= (int)n; ++i)
    cin >> a[i].first >> a[i].second, maxVal = max(maxVal, a[i].second);
  sol();
  return 0;
}
