As the name of the task implies, you are asked to do some work with segments and trees.

Recall that a tree is a connected undirected graph such that there is exactly one simple path between every pair of its vertices.

You are given n segments [l_1, r_1], [l_2, r_2], ..., [l_n, r_n], l_i < r_i for every i. It is guaranteed that all segments' endpoints are integers, and all endpoints are unique — there is no pair of segments such that they start in the same point, end in the same point or one starts in the same point the other one ends.

Let's generate a graph with n vertices from these segments. Vertices v and u are connected by an edge if and only if segments [l_v, r_v] and [l_u, r_u] intersect and neither of it lies fully inside the other one.

For example, pairs ([1, 3], [2, 4]) and ([5, 10], [3, 7]) will induce the edges but pairs ([1, 2], [3, 4]) and ([5, 7], [3, 10]) will not.

Determine if the resulting graph is a tree or not.

Input

The first line contains a single integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the number of segments.

The i-th of the next n lines contain the description of the i-th segment — two integers l_i and r_i (1 ≤ l_i < r_i ≤ 2n).

It is guaranteed that all segments borders are pairwise distinct. 

Output

Print "YES" if the resulting graph is a tree and "NO" otherwise.

Examples

Input


6
9 12
2 11
1 3
6 10
5 7
4 8


Output


YES


Input


5
1 3
2 4
5 9
6 8
7 10


Output


NO


Input


5
5 8
3 6
2 9
7 10
1 4


Output


NO

Note

The graph corresponding to the first example:

<image>

The graph corresponding to the second example:

<image>

The graph corresponding to the third example:

<image>
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
void tracer(istream_iterator<string> it) {}
template <typename T, typename... Args>
void tracer(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << " | ";
  tracer(++it, args...);
}
const long long MOD = 1e9 + 7;
const long double err = 1e-10;
const int N = 5e5 + 5;
set<pair<pair<int, int>, int>> st;
vector<vector<int>> adj(N);
int connected = 0;
vector<bool> vis(N, 0);
void no() {
  cout << "NO\n";
  exit(0);
}
void dfs(int u, int par = -1) {
  vis[u] = 1;
  connected++;
  for (auto v : adj[u]) {
    if (v == par) continue;
    if (vis[v]) no();
    dfs(v, u);
  }
}
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> V(n);
  for (int i = 0; i < n; i++) {
    cin >> V[i].second >> V[i].first;
    st.insert(make_pair(make_pair(V[i].second, V[i].first), i + 1));
  }
  sort((V).begin(), (V).end());
  for (int i = 0; i < n; i++) {
    int us = V[i].second, ue = V[i].first, idx;
    auto mit = st.lower_bound(make_pair(make_pair(us, ue), -1));
    idx = (*mit).second;
    auto it = next(mit);
    st.erase(mit);
    int pmn = 2e9;
    while (it != st.end()) {
      auto prr = *it;
      int vs = prr.first.first, ve = prr.first.second, vidx = prr.second;
      if (vs > ue) break;
      if (ve > pmn) no();
      pmn = ve;
      adj[idx].push_back(vidx);
      adj[vidx].push_back(idx);
      it++;
    }
  }
  dfs(1);
  if (connected < n) no();
  cout << "YES\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  for (int i = 1; i <= T; i++) {
    solve();
  }
  return 0;
}
