Polycarp is a great fan of television.

He wrote down all the TV programs he is interested in for today. His list contains n shows, i-th of them starts at moment l_{i} and ends at moment r_{i}.

Polycarp owns two TVs. He can watch two different shows simultaneously with two TVs but he can only watch one show at any given moment on a single TV. If one show ends at the same moment some other show starts then you can't watch them on a single TV.

Polycarp wants to check out all n shows. Are two TVs enough to do so?


-----Input-----

The first line contains one integer n (1 ≤ n ≤ 2·10^5) — the number of shows.

Each of the next n lines contains two integers l_{i} and r_{i} (0 ≤ l_{i} < r_{i} ≤ 10^9) — starting and ending time of i-th show.


-----Output-----

If Polycarp is able to check out all the shows using only two TVs then print "YES" (without quotes). Otherwise, print "NO" (without quotes).


-----Examples-----
Input
3
1 2
2 3
4 5

Output
YES

Input
4
1 2
2 3
2 3
1 2

Output
NO

Difficulty: interview

Starter code:

Solutions:
n = int(input())
shows = []
for i in range(n):
  l, r = map(int, input().split())
  shows.append((l,r))
  
shows.sort()

a_endtime, b_endtime = -1, -1
for show in shows:
  if show[0] <= a_endtime:
    print('NO')
    break
  else:
    a_endtime = show[1]
    if a_endtime > b_endtime:
      a_endtime, b_endtime = b_endtime, a_endtime
  
else:
  print('YES')

tv1 = -1
tv2 = -1

shows = []
for _ in range(int(input())):
    l, r = map(int, input().split())
    shows.append((l, r))
shows.sort(key = lambda x: x[0])
for l, r in shows:
    if tv1 < l:
        tv1 = r
    elif tv2 < l:
        tv2 = r
    else:
        print("NO")
        break
else:
    print("YES")

# C. Two TVs
n = int(input())

events = []
for i in range(n):
	a, b = list(map(int, input().split()))
	events.append((a, +1))
	events.append((b, -1))

events = sorted(events, key=lambda x: (x[0], -x[1]))

max_shows = 0
cur_shows = 0

for _, e in events:
	cur_shows += e
	max_shows = max(max_shows, cur_shows)

if max_shows > 2:
	print('NO')
else:
	print('YES')


read = lambda: map(int, input().split())
n = int(input())
ev = []
for i in range(n):
    l, r = read()
    r += 1
    ev.append((l, 1))
    ev.append((r, -1))
ev.sort()
bal = 0
flag = 1
for x, t in ev:
    bal += t
    if bal > 2:
        flag = 0
        break
print('YES' if flag else 'NO')

n = int(input())

events = []
# -1 - start
for i in range(n):
    l, r = list(map(int, input().split()))
    events.append((l, -1))
    events.append((r, 1))
events = sorted(events)
bal = 0
result = True
for item in events:
    #print(item)
    bal += item[1]*(-1)
    #print(bal)
    if bal > 2:
        result = False
        print("NO")
        break
if(result):
    print("YES")


n = int(input())
pr = []
flag = True
for i in range(n):
    pr.append(tuple(map(int,input().split())))
pr.sort()
tel1, tel2 = -1, -1
flag = True
for i in range(n):
    if tel1 < pr[i][0]:
        tel1 = pr[i][1]
    elif tel2 < pr[i][0]:
        tel2 = pr[i][1]
    else:
        flag = False
        break
if flag:
    print("YES")
else:
    print("NO")

n = int(input())

d = []
for i in range(n):
    a, b = list(map(int, input().split()))
    d.append((a, -1))
    d.append((b, 1))

d.sort()
t = 0
for a, b in d:
    t -= b
    if t > 2:
        print("NO")
        return
print("YES")        


n = int(input())
segment = []

for _ in range(n):
    segment.append(list(map(int, input().split())))

segment.sort(key = lambda x: x[0])

start1 = 0
end1 = -float('inf')
start2 = 0
end2 = -float('inf')

for x in segment:
    start = x[0]
    end = x[1]

    if start > end1:
        start1 = start
        end1 = end
    elif start > end2:
        start2 = start
        end2 = end
    else:
        print("NO")
        return

print("YES")

n = int(input())

shows = []

for i in range(n):
    shows.append(list([int(s) for s in input().split()]))

shows = sorted(shows)

t = [-1,-1]
violate = False

for s in shows:
    if s[0] > t[0]:
        t[0] = s[1]
    elif s[0] > t[1]:
        t[1] = s[1]
    else:
        violate = True
        break

if not violate:
    print('YES')
else:
    print('NO')




def main():
    n = int(input())

    events = []

    for _ in range(n):
        l, r = (int(x) for x in input().split())

        events.append((l, 1))
        events.append((r + 1, -1))

    cur = 0
    for _, event in sorted(events):
        cur += event
        if cur > 2:
            print("NO")
            break
    else:
        print("YES")


def __starting_point():
    main()

__starting_point()

n = int(input())
show = [list(map(int, input().split())) for _ in range(n)]
show.sort(key=lambda x:x[0])
tv1 = tv2 = -1
ans = True
for i in range(n):
    if show[i][0] > tv1:
        tv1 = show[i][1]
    elif show[i][0] > tv2:
        tv2 = show[i][1]
    else:
        ans = False
        break
print("YES" if ans else "NO")
        
    


from operator import itemgetter
n = int(input())
A = []
for i in range(n):
    A.append([int(i) for i in input().split()])
A = sorted(A, key = itemgetter(0))
first_tv = []
second_tv = []
first_end = -1
second_end = -1
for i in range(n):
    if A[i][0] > first_end:
        first_end = A[i][1]
    elif A[i][0] > second_end:
        second_end = A[i][1]
    else:
        print('NO')
        break
else:
    print('YES')

from math import inf

n=int(input())
a=[]
for _ in range(n):
    b=list(map(int,input().split()))
    a.append(b)
a.sort()


def f(a):
    i=a[0]
    j=a[1]
    q=2
    k=0
    while 1:
        if a[q][0]==k:
            return 'NO'
        if i[1]==k:
            i=a[q]
            q+=1
        if len(a)==q:
            return 'YES'
        if j[1]==k:
            j=a[q]
            q+=1
        if len(a)==q:
            return 'YES'
        k=min(i[1],j[1],a[q][0])

if n<=2:
    print('YES')
else:
    print(f(a))
#print(' '.join([str(i) for i in a]))


import sys
n=int(input())
x=[]
z=[]
for i in range(n):
    a,b=map(int, input().split())
    x.append(a)
    z.append(b+1)
x.sort()
z.sort()
s=''
sc=0
k=0
j=0
while (len(x)!=k and len(z)!=j):
        if x[k]>z[j]:
            s+=')'
            j+=1
        elif x[k]<z[j]:
            s+='('
            k+=1
        else:
            k+=1
            j+=1
if len(z)-j>0:
    s+=(')'*(len(z)-j))
#print(s)
for i in range(len(s)):
    if sc>2:
        print('NO')
        return
    if s[i]=='(':
        sc+=1
    else:
        sc-=1
    
print('YES')

n = int(input())

shows = []
for i in range(n):
	shows.append([int(x) for x in input().split()])

shows = sorted(shows, key=lambda tup: tup[0])

def fit(show, tv):
	if show[1]<tv[0] or show[0]>tv[1]:
		return True
	return False

def main():
	if n<2:
		print("YES")
		return
	tv1 = shows[0]
	tv2 = shows[1]
	for show in shows[2:]:
		if fit(show, tv1):
			tv1 = show
		elif fit(show, tv2):
			tv2 = show
		else:
			print("NO")
			return
	print("YES")
	return

main()

n=int(input())
a,b=[],[]
for i in range(n):
    t=[int(i) for i in input().split()]
    a.append(t[0])
    b.append(t[1])
a.sort()
b.sort()
i=j=0
ans=0

while ans<=2 and i<n and j<n:
    """
    print(a[i],b[j])
    print(i,j,'\n')
    """
    if a[i]<=b[j]:
        ans+=1
        i+=1
    else:
        ans-=1
        j+=1

if ans>2: print("NO")
else: print("YES")


n=int(input())
c=[]
for i in range(n):
    a=list(map(int,input().strip().split(' ')))
    c.append(a)
c.sort()
if(n<=2):
    print("YES")
else:
    u=0
    tv1=[]
    tv2=[]
    tv1.append(c[0])
    tv2.append(c[1])
    for i in range(2,n):
        if(c[i][0]>tv1[0][1]):
            tv1[0]=c[i]
        elif(c[i][0]>tv2[0][1]):
            tv2[0]=c[i]
        else:
            u=1
            break
    if(u==0):
        print("YES")
    else:
        print("NO")


n = int(input())
t = [0] * n
t1 = -1
t2 = -1
ff = True
for i in range(n):
    a, b = list(map(int, input().split()))
    t[i] = (a, b)
t.sort()
for i in range(n):
    bl = False
    if t[i][0] > t1:
        t1 = t[i][1]
        bl = True
    if not bl and t[i][0] > t2:
        t2 = t[i][1]
        bl = True
    if not bl:
        ff = False
        break
if ff:
    print("YES")
else:
    print("NO")


n = int(input())
t = []
flag = True
for i in range(n):
    t.append(list(map(int,input().split(' '))))
t.sort()
l1,l2 = -1,-1
for i in range(n) :
    if t[i][0] > l1 and t[i][0] > l2 :
        if l1 > l2 :
            l1 = t[i][1]
        else :
            l2 = t[i][1]
    elif t[i][0] > l1 :
        l1 = t[i][1]
    elif t[i][0] > l2 :
        l2 = t[i][1]
    else :
        print("NO")
        flag = False
        break
if (flag) :
    print("YES")

import sys
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
a = sorted(a)
count = 0
c1 = c2 = -1
for i in a:
    if i[0] > c1:
        c1 = i[1]
    elif i[0] > c2:
        c2 = i[1]
    else:
        print('NO')
        return
print('YES')


def lol(a):
    c = 0
    for x in a:
        if x[1]==1:
            c+=1
        else:
            c-=1
        if c>=3:
            return 0
    return 1

n = int(input())
a = []
for _ in range(n):
    x,y = map(int,input().split())
    a.append([x,1])
    a.append([y,2])
a = sorted(a)
print("YES" if lol(a) else "NO")