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
'''
Ask what parent(s)? (qr-1, qg-1?,qg)
Ask when filled?

if parents not filled by pour, return 0

  1
 1 1


7
3
1
5050
15
1
100000009
33
17
1000000000
99
50
1000000000
99
82
1000000000
67
22
6
3
1
'''
import sys, io, os
import math
import bisect
import heapq
import string
import re
from decimal import *
from collections import defaultdict,Counter,deque
input = sys.stdin.readline
sys.setrecursionlimit(100000) 
 
def I():
    return input()
 
def II():
    return int(input())
 
def MII():
    return map(int, input().split())
 
def LI():
    return list(input().split())
 
def LII():
    return list(map(int, input().split()))
 
def GMI():
    return map(lambda x: int(x) - 1, input().split())
 
def LGMI():
    return list(map(lambda x: int(x) - 1, input().split()))
 
def WRITE(out):
  return print('\n'.join(map(str, out)))
 
def WS(out):
  return print(' '.join(map(str, out)))
 
def WNS(out):
  return print(''.join(map(str, out)))

def WSNOPRINT(out):
  return ''.join(map(str, out))


'''
'''
def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError

def find_lt(a, x):
    'Find rightmost value less than x'
    i = bisect_left(a, x)
    if i:
        return a[i-1]
    raise ValueError

def find_le(a, x):
    'Find rightmost value less than or equal to x'
    i = bisect_right(a, x)
    if i:
        return a[i-1]
    raise ValueError

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bisect_right(a, x)
    if i != len(a):
        return a[i]
    raise ValueError

def find_ge(a, x):
    'Find leftmost item greater than or equal to x'
    i = bisect_left(a, x)
    if i != len(a):
        return a[i]
    raise ValueError

"""
"""
def solve():
    x = math.inf
    for _ in range(II()):
        w, h = MII()
        mx = max(w,h)
        mn = min(w,h)
        if mx <= x:
            x = mx
        elif mn <= x:
            x = mn
        else:
            print('NO')
            return
    print('YES')

def main():
    solve()

main()
