human
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:


The graph corresponding to the second example:


The graph corresponding to the third example:

Solve the task in PYTHON3.
assistant
#Here is Python code to determine if the resulting graph is a tree or not.

import sys
 
class segmTree():
    def __init__(self, size=None, array=None):
        if array is not None:
            size = len(array)
        N = 1
        while N < size:
            N <<= 1
        self.N = N
        self.tree = [0] * (2*self.N)
        if array is not None:
            for i in range(size):
                self.tree[i+self.N] = array[i]
            self.build()
 
    def build(self):
        for i in range(self.N - 1, 0, -1):
            self.tree[i] = self.tree[i<<1] + self.tree[i<<1|1]
 
    def add(self, i, value=1):
        i += self.N
        while i > 0:
            self.tree[i] += value
            i >>= 1
 
    def findNonzeros(self, l, r):
        N = self.N
        l += N
        r += N
        cand = []
        while l < r:
            if l & 1:
                if self.tree[l]:
                    cand.append(l)
                l += 1
            if r & 1:
                r -= 1
                if self.tree[r]:
                    cand.append(r)
            l >>= 1
            r >>= 1
        ans = []
        while cand:
            i = cand.pop()
            if i < N:
                i <<= 1
                if self.tree[i]:
                    cand.append(i)
                if self.tree[i|1]:
                    cand.append(i|1)
            else:
                ans.append(i - N)
        return ans
 
# inf = open('input.txt', 'r')
# reader = (line.rstrip() for line in inf)
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
            
n = int(input())
segm = [0] * (2 * n + 1)
edge = [0] * (2 * n + 1)
 
for i in range(n):
    l, r = map(int, input().split())
    segm[l] = segm[r] = i
    edge[l] = edge[r] = r
    
# inf.close()
 
opened = segmTree(size=2*n+1)
g = [[] for _ in range(n)]
ctr = 0
for e in range(1, 2 * n + 1):
    r = edge[e]
    if e == r:
        opened.add(e, -1)
    else:
        opened.add(r, 1)
        for R in opened.findNonzeros(0, r):
            ctr += 1
            if ctr >= n:
                print('NO')
               ...