There are $n$ rectangles in a row. You can either turn each rectangle by $90$ degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can turn all or none of them. You can not change the order of the rectangles.

Find out if there is a way to make the rectangles go in order of non-ascending height. In other words, after all the turns, a height of every rectangle has to be not greater than the height of the previous rectangle (if it is such).
The first line contains a single integer $n$ ($1 \leq n \leq 10^5$) — the number of rectangles.

Each of the next $n$ lines contains two integers $w_i$ and $h_i$ ($1 \leq w_i, h_i \leq 10^9$) — the width and the height of the $i$-th rectangle.
3
3 4
4 6
3 5
YES
2
3 4
5 5
NO
10
4 3
1 1
6 5
4 5
2 4
9 5
7 9
9 2
4 10
10 1
NO
10
241724251 76314740
80658193 177743680
213953908 406274173
485639518 859188055
103578427 56645210
611931853 374099541
916667853 408945969
677773241 808703176
575586508 440395988
450102404 244301685
NO
10
706794178 103578427
431808055 641644550
715688799 406274173
767234853 345348548
241724251 408945969
808703176 213953908
185314264 16672343
553496707 152702033
105991807 76314740
61409204 244301685
YES
1
1 1
YES
4
10 10
8 8
8 15
9 9
NO
4
10 10
8 8
8 9
9 9
NO
3
3 4
4 5
5 5
NO
3
10 10
5 5
10 10
NO
3
5 5
4 6
5 5
NO
3
5 7
3 9
8 10
NO
3
10 10
1 1
2 2
NO
3
3 5
1 2
3 4
NO
3
4 8
6 25
12 12
NO
3
3 5
4 10
6 6
NO
3
200 200
300 20
50 50
NO
3
5 3
6 4
5 5
NO
4
5 5
4 6
4 4
5 5
NO
3
10 10
1 100
20 20
NO
4
1 3
2 4
3 5
4 6
NO
3
1 60
70 55
56 80
NO
3
5 6
5 7
6 8
NO
3
6 6
5 7
6 6
NO
n = int(input())
a = []

for i in range(n):
    w, h = map(int, input().split())
    a.append([w, h])

a.reverse()

lst = 0
for i in range(n):
    if a[i][0] > a[i][1]:
        a[i][0], a[i][1] = a[i][1], a[i][0]
    
    if a[i][0] >= lst:
        lst = a[i][0]
    elif a[i][1] >= lst:
        lst = a[i][1]
    else:
        print("NO")
        exit()

print("YES")