Pig is visiting a friend.

Pig's house is located at point 0, and his friend's house is located at point m on an axis.

Pig can use teleports to move along the axis.

To use a teleport, Pig should come to a certain point (where the teleport is located) and choose where to move: for each teleport there is the rightmost point it can move Pig to, this point is known as the limit of the teleport.

Formally, a teleport located at point x with limit y can move Pig from point x to any point within the segment [x; y], including the bounds. [Image] 

Determine if Pig can visit the friend using teleports only, or he should use his car.


-----Input-----

The first line contains two integers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of teleports and the location of the friend's house.

The next n lines contain information about teleports.

The i-th of these lines contains two integers a_{i} and b_{i} (0 ≤ a_{i} ≤ b_{i} ≤ m), where a_{i} is the location of the i-th teleport, and b_{i} is its limit.

It is guaranteed that a_{i} ≥ a_{i} - 1 for every i (2 ≤ i ≤ n).


-----Output-----

Print "YES" if there is a path from Pig's house to his friend's house that uses only teleports, and "NO" otherwise.

You can print each letter in arbitrary case (upper or lower).


-----Examples-----
Input
3 5
0 2
2 4
3 5

Output
YES

Input
3 7
0 4
2 5
6 7

Output
NO



-----Note-----

The first example is shown on the picture below: [Image] 

Pig can use the first teleport from his house (point 0) to reach point 2, then using the second teleport go from point 2 to point 3, then using the third teleport go from point 3 to point 5, where his friend lives.

The second example is shown on the picture below: [Image] 

You can see that there is no path from Pig's house to his friend's house that uses only teleports.

Difficulty: EASY
Tags: Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
(n, m) = map(int, input().split())
p = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a <= p <= b:
		p = b
		if p >= m:
			print('YES')
			exit()
print('NO')


(m, n) = map(int, input().split())
a = []
s = 1
for i in range(m):
	a.append(list(map(int, input().split())))
for i in range(m):
	for j in range(1, m):
		if a[j][0] < a[j - 1][0]:
			(a[j][0], a[j - 1][0]) = (a[j - 1][0], a[j][0])
			(a[j][1], a[j - 1][1]) = (a[j - 1][1], a[j][1])
if a[0][0] == 0:
	q = a[0][1]
	for i in range(1, m):
		if a[i][0] <= q:
			if a[i][1] > q:
				q = a[i][1]
		elif a[i][0] > q:
			break
else:
	q = n - 1
if n > q:
	print('NO')
else:
	print('YES')


(N, M) = list(map(int, input().split()))
prevB = 0
found = False
for n in range(N):
	(a, b) = list(map(int, input().split()))
	if prevB >= a:
		prevB = max(b, prevB)
if M <= prevB:
	found = True
if found:
	print('YES')
else:
	print('NO')


a = input()
list1 = a.split(' ')
n = int(list1[0])
m = int(list1[1])
i = 1
teleportlocation = [0]
teleportrange = [0]
while i <= n:
	tempstring = input()
	list1 = tempstring.split(' ')
	list1[0] = int(list1[0])
	list1[1] = int(list1[1])
	teleportlocation.insert(i, list1[0])
	teleportrange.insert(i, list1[1])
	i = i + 1
testlist = [0] * m
i = 1
while i <= n:
	x = teleportlocation[i]
	y = teleportrange[i]
	testlist[x:y] = [1] * (y - x)
	i = i + 1
final = 1
for i in testlist:
	if i == 0:
		final = 0
		break
if final == 0:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
ll = [0] * m
for i in range(n):
	(a, b) = map(int, input().split())
	for j in range(a, b):
		ll[j] = 1
fl = True
for i in range(m):
	if ll[i] != 1:
		fl = False
if fl:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ans = 'YES'
(a, b) = map(int, input().split())
if a == 0:
	for i in range(n - 1):
		(ai, bi) = map(int, input().split())
		if ai <= b:
			if bi >= b:
				b = bi
		else:
			ans = 'NO'
	if b < m:
		ans = 'NO'
else:
	ans = 'NO'
print(ans)


(n, m) = map(int, input().split())
l = [0] * 1000
f = 1
for i in range(n):
	(a, b) = map(int, input().split())
	if a == 0:
		l[0] = 1
	a += 1
	for j in range(a, b + 1):
		l[j] = 1
for i in range(m + 1):
	if l[i] == 0:
		f = 0
		break
if f == 0:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
flag = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if flag < a:
		break
	flag = max(b, flag)
if flag == m:
	print('YES')
else:
	print('NO')


(n, m) = [int(num) for num in input().strip().split()]
curr = 0
for i in range(n):
	(a, b) = [int(num) for num in input().strip().split()]
	if a <= curr:
		curr = max(curr, b)
	else:
		break
if curr < m:
	print('NO')
else:
	print('YES')


R = lambda : map(int, input().split())
(n, m) = R()
l = [list(R()) for _ in range(n)]
i = e = 0
while i < len(l) and l[i][0] <= e:
	e = max(e, l[i][1])
	if e >= m:
		print('YES')
		break
	i += 1
else:
	print('NO')


(n, m) = map(int, input().split())
z = 0
for x in range(n):
	(a, b) = map(int, input().split())
	if z < a:
		break
	elif b > z:
		z = b
if m > z:
	print('NO')
else:
	print('YES')


def func(visited, index, arr, n, lol):
	if lol[index] == 1:
		return
	lol[index] = 1
	if index >= n:
		return
	for i in range(arr[index][0], arr[index][1] + 1):
		visited[i] = 1
		for j in range(index + 1, n):
			if arr[j][0] == i:
				func(visited, j, arr, n, lol)
arr = []
(n, m) = map(int, input().strip().split(' '))
lol = [0 for i in range(1000)]
for i in range(n):
	a = list(map(int, input().strip().split(' ')))
	arr.append(a)
visited = [0 for i in range(1000)]
if arr[0][0] != 0:
	print('NO')
else:
	func(visited, 0, arr, n, lol)
	if visited[m] == 1:
		print('YES')
	else:
		print('NO')


(n, m) = [int(v) for v in input().split()]
teleports = []
for _ in range(n):
	(a, b) = [int(v) for v in input().split()]
	teleports.append((a, b))
reachable = [False] * (m + 1)
reachable[0] = True
for (a, b) in teleports:
	if reachable[a]:
		for i in range(a + 1, b + 1):
			reachable[i] = True
print(['NO', 'YES'][reachable[m]])


values = [int(m) for m in input().split()]
dict = {}
for i in range(values[0]):
	ranges = [int(m) for m in input().split()]
	for value in range(ranges[0], ranges[1]):
		dict[value] = value + 1
	way_found = True
	for i in range(0, values[1]):
		if not i in dict:
			way_found = False
print('YES' if way_found else 'NO')


(n, m) = map(int, input().split())
loc = []
for _ in range(n):
	(x, y) = map(int, input().split())
	loc.append((x, y))
flag = 1
found = 0
curr = 0
for (x, y) in loc:
	if x <= curr:
		if y > curr:
			curr = y
		if m <= curr:
			found = 1
			break
	elif x > curr:
		break
if found:
	print('yes')
else:
	print('no')


(num_teleports, destination) = map(int, input('').split())
start_points = []
end_points = []
i = 0
while i < num_teleports:
	(h, e) = map(int, input('').split())
	i += 1
	start_points.append(h)
	end_points.append(e)
max_length = end_points[0]
if start_points[0] != 0:
	print('No')
	exit(0)
for e in range(1, num_teleports):
	if start_points[e] <= max_length:
		max_length = max(end_points[e], max_length)
		continue
	else:
		print('No')
		exit(0)
if max_length >= destination:
	print('Yes')
	exit(0)
else:
	print('No')
	exit(0)


axis = [0] * 105
(n, m) = map(int, input().split())
for _ in range(n):
	(x, y) = map(int, input().split())
	axis[x + 1:y + 1] = [1] * (y - x)
for i in range(1, m + 1):
	if not axis[i]:
		print('No')
		exit(0)
print('YES')


def max(a, b):
	a = int(a)
	b = int(b)
	if a > b:
		return a
	else:
		return b
while True:
	try:
		(n, m) = map(int, input().split())
		now = 0
		for i in range(n):
			(a, b) = map(int, input().split())
			if a <= now:
				now = max(now, b)
		if now >= m:
			print('YES')
		else:
			print('NO')
	except:
		break


def main():
	(n, m) = [int(x) for x in input().strip().split()]
	a = []
	for i in range(n):
		a.append(tuple((int(x) for x in input().strip().split())))
	if a[0][0] != 0:
		print('NO')
		return
	f = 0
	for i in range(n):
		(x, y) = a[i]
		if y > f and x <= f:
			f = y
	if f >= m:
		print('YES')
	else:
		print('NO')
main()


(n, m) = map(int, input().split())
ma = 0
flag = -1
zf = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a == 0 and (not i):
		zf = 1
	elif not i:
		flag = 0
	if flag == -1:
		if a <= ma and m in range(min(a, ma), max(ma, b) + 1):
			flag = 1
		elif a > ma:
			flag = 0
	if flag == -1:
		if m in range(min(a, ma), max(ma, b) + 1):
			flag = 1
	ma = max(ma, b)
if not flag or flag == -1:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
l = [0 for i in range(120)]
l[0] = 1
for i in range(n):
	(a, b) = map(int, input().split())
	for i in range(a + 1, b + 1):
		l[i] = 1
for i in range(0, m + 1):
	if l[i] == 0:
		print('NO')
		exit()
print('YES')


(n, m) = list(map(int, input().split()))
x = 0
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	if x >= a:
		x = max(x, b)
if x >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
f = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if i == 0 and a != 0:
		f = 0
		break
	if i == 0 and a == 0:
		p = a
		q = b
		if q >= m:
			f = 1
			break
	if i > 0:
		if q >= a and q <= b:
			p = a
			q = b
		if q < a:
			f = 0
			break
		if q >= m:
			f = 1
			break
if f == 1:
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
l = []
for i in range(n):
	l.append([int(j) for j in input().split()])
ans = 1
location = m
i = n - 1
while ans == 1 and location > 0:
	ans = 0
	for j in range(i, -1, -1):
		if l[j][1] >= location:
			ans = 1
			location = l[j][0]
			i = j - 1
			break
if ans == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = [0 for i in range(m)]
for _ in range(n):
	(a, b) = map(int, input().split())
	for i in range(a, b):
		l[i] = 1
if not all(l):
	print('NO')
else:
	print('YES')


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
for _ in range(T):
	(n, m) = map(int, input().split())
	a = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		if x <= a:
			a = max(a, y)
	if a >= m:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().strip().split(' '))
pos = 0
for x in range(n):
	(a, b) = map(int, input().strip().split(' '))
	if pos >= a:
		pos = max(pos, b)
	else:
		break
print('yes' if pos >= m else 'no')


(n, m) = map(int, input().split())
check = 0
l1 = []
l2 = []
for i in range(n):
	(t, l) = map(int, input().split())
	l1.append(t)
	l2.append(l)
for i in range(n):
	if l1[i] > check:
		print('NO')
		exit(0)
	if l2[i] > check:
		check = l2[i]
	if check >= m:
		print('YES')
		exit(0)
if check < m:
	print('NO')
	exit(0)
print('YES')


t = input().split(' ')
n = int(t[0])
m = int(t[1])
rch = 0
boo = True
for i in range(n):
	s = input().split(' ')
	if int(s[0]) > rch:
		boo = False
		break
	elif int(s[1]) > rch:
		rch = int(s[1])
	else:
		pass
if rch < m:
	boo = False
if boo:
	print('YES')
else:
	print('NO')


inpt = input().split()
n = int(inpt[0])
m = int(inpt[1])
data = input().split()
startPosition = int(data[0])
maxPosition = int(data[1])
for i in range(1, n):
	data = input().split()
	position = int(data[0])
	dist = int(data[1])
	if maxPosition >= position:
		maxPosition = max(maxPosition, dist)
if maxPosition == m and startPosition == 0:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
(x, y) = map(int, input().split())
if x == 0:
	max_lim = y
	for i in range(n - 1):
		(x1, y1) = map(int, input().split())
		if x1 <= max_lim:
			max_lim = max(y1, max_lim)
		else:
			break
		(x, y) = (x1, y1)
	if max_lim >= k:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import sys

def main():
	reachable = [False] * 666
	(n, m) = map(int, input().split())
	for _ in range(n):
		(l, r) = map(int, input().split())
		for i in range(l + 1, r + 1):
			reachable[i] = True
	print('YES' if all((reachable[i] for i in range(1, m + 1))) else 'NO')
main()


(n, m) = (int(i) for i in input().split())
p = 0
for i in range(n):
	(a, b) = (int(i) for i in input().split())
	if a <= p:
		p = max(p, b)
if p == m:
	print('YES')
else:
	print('NO')


def main():
	from collections import defaultdict
	(n, m) = map(int, input().split(' '))
	l = [0] * 101
	end = False
	for i in range(n):
		(a, b) = map(int, input().split(' '))
		if b == m:
			end = True
		for i in range(a, b):
			l[i] += 1
	for i in range(0, m):
		if l[i] == 0:
			return False
	return end
print('YES' if main() else 'NO')


(n, m) = map(int, input().split())
a = 0
b = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x <= a:
		if a < y:
			a = y
		b += 1
	if a >= m:
		print('YES')
		b = n
		break
if a < m:
	print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	(x, y) = map(int, input().strip().split())
	a.append((x, y))
(s, p) = a[0]
if s != 0:
	print('NO')
	exit()
for i in range(n - 1):
	(xi, xf) = a[i]
	for j in range(i + 1, n):
		(x2i, x2f) = a[j]
		if p >= x2i:
			p = max(p, max(x2f, xf))
			break
		elif p >= m:
			print('YES')
			exit()
		else:
			print('NO')
			exit()
if p >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	y = []
	(a, b) = map(int, input().split())
	y = [a, b]
	l.append(y)
l.sort()
if l[0][0] == 0:
	t = l[0][1]
	for k in range(1, n):
		if l[k][0] <= t and l[k][1] > t:
			t = l[k][1]
	if t >= m:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(z, zz, dgraphs, mod) = (input, lambda : list(map(int, z().split())), {}, 10 ** 9 + 7)
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, m) = zz()
(a, b) = zz()
x = 0
if a == 0:
	x = b
for _ in range(n - 1):
	(a, b) = zz()
	if x == 0:
		if a == 0:
			x = b
			continue
	if a <= x:
		if x <= b:
			x = b
if x >= m:
	print('YES')
else:
	print('NO')


I = lambda : map(int, input().split())
(n, m) = I()
x = 0
for _ in range(n):
	(a, b) = I()
	if x < a:
		break
	x = max(x, b)
print('NO' if x < m else 'YES')


import bisect

def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
[n, m] = list(map(int, input().split()))
tels = list()
for i in range(n):
	tels.append(list(map(int, input().split())))
(l, r) = tels[0]
for i in range(1, n):
	(a, b) = tels[i]
	if r < a:
		break
	r = max(r, b)
if r >= m and l <= 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
mx = 0
ch = 1
curr = 0
while n:
	n -= 1
	(a, b) = map(int, input().split())
	if curr < a and mx < a:
		ch = 0
	if ch == 1:
		if b > mx:
			mx = b
		curr = b
if curr >= m or mx >= m:
	print('YES')
else:
	print('NO')


import urllib.request

def main():
	(n, k) = [int(i) for i in input().split()]
	tps = []
	maxi = k
	for j in range(n):
		(s, l) = [int(i) for i in input().split()]
		if max([s, l]) > maxi:
			maxi = max([s, l])
		tps.append([s, l])
	maps = [0 for i in range(maxi)]
	for tp in tps:
		for i in range(tp[0], tp[1]):
			maps[i] = 1
	for i in range(k):
		if maps[i] == 0:
			print('NO')
			return
	print('YES')
main()


(n, m) = map(int, input().split())
tps = [list(map(int, input().split())) for _ in range(n)]
canGetThere = [False for _ in range(m + 1)]
canGetThere[0] = True
for a in tps:
	if canGetThere[a[0]]:
		for b in range(a[0], min(a[1], m) + 1):
			canGetThere[b] = True
print('YES' if canGetThere[m] else 'NO')


import sys
(n, m) = list(map(int, input().strip().split()))
start = 0
konec = 0
for _ in range(n):
	(a, b) = list(map(int, input().strip().split()))
	if start <= a <= konec:
		konec = max(konec, b)
	else:
		print('NO')
		sys.exit(0)
if konec >= m:
	print('YES')
else:
	print('NO')


(n, dest) = list(map(int, input().strip('\n').split(' ')))
all_numbers = set()
for i in range(n):
	pair = list(map(int, input().strip('\n').split(' ')))
	for j in range(pair[0], pair[1]):
		all_numbers.add(j)
can = True
for i in range(0, dest):
	if i not in all_numbers:
		can = False
if can:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
pre = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if a <= pre <= b:
		pre = b
if pre == m:
	print('YES')
else:
	print('NO')


(n, home) = map(int, input().split())
c = []
for i in range(n):
	a = list(map(int, input().split()))
	if a[1] == home:
		homeindex = i
	c.append(a)
solved = 0
count = 0
try:
	for j in range(n * n):
		for i in range(n):
			if c[i][0] <= c[homeindex][0] <= c[i][1]:
				homeindex = i
				if c[homeindex][0] == 0:
					print('YES')
					solved = 1
					count = 0
					break
				count += 1
		if solved == 1:
			break
	if count != 0:
		print('NO')
except NameError:
	print('NO')


(n, m) = input().split(' ')
teleporter_list = list()
for _ in range(int(n)):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	teleporter_list.append((a, b))
pig = 0
for (a, b) in teleporter_list:
	if pig in range(a, b + 1) and int(m) in range(a, b + 1):
		print('yes')
		quit()
	elif pig in range(a, b + 1):
		pig = b
print('no')


(n, m) = list(map(int, input().split()))
A = []
B = []
CanReach = []
start_idx = 0
end_idx = 0
for i in range(n):
	(a, b) = list(map(int, input().split()))
	A.append(a)
	B.append(b)
memo = {}

def best(i):
	if A[i] <= m <= B[i]:
		return True
	if i in memo:
		return memo[i]
	Best = False
	for j in range(i + 1, n):
		if A[j] <= B[i] <= B[j]:
			Best |= best(j)
	if i not in memo:
		memo[i] = Best
	return Best
for i in range(n):
	if A[i] == 0:
		if best(i):
			print('YES')
			exit(0)
print('NO')


(n, m) = map(int, input().split())
f = 1
upto = 0
for i in range(n):
	(a, lim) = map(int, input().split())
	if a > upto:
		if f:
			tot = upto
		f = 0
	else:
		upto = max(upto, lim)
if f:
	tot = upto
print('YES' if f and tot >= m else 'NO')


(n, m) = map(int, input().split())
(x, y) = map(int, input().split())
if x != 0:
	print('NO')
	exit()
maxr = y
for i in range(n - 1):
	(x, y) = map(int, input().split())
	if x > maxr:
		print('NO')
		break
	maxr = max(y, maxr)
else:
	if maxr == m:
		print('YES')
	else:
		print('NO')


INF = 10 ** 10

def main():
	print = out.append
	P = 10 ** 9 + 7
	(n, m) = get_list()
	teleports = [get_list() for _ in range(n)]
	teleports.sort()
	rightmost = 0
	for (l, r) in teleports:
		if l > rightmost:
			print('NO')
			return
		else:
			rightmost = max(r, rightmost)
		if rightmost >= m:
			print('YES')
			return
	print('NO')
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
main()
print(*out, sep='\n')


(n, m) = map(int, input().split())
prev = 0
from sys import exit
for i in range(n):
	(a, b) = map(int, input().split())
	if prev < a:
		print('NO')
		exit()
	prev = max(prev, b)
if prev < m:
	print('NO')
	exit()
print('YES')


(n, m) = map(int, input().split())
flag = True
st = []
for i in range(n):
	(a, b) = map(int, input().split())
	st.append([a, b])
st2 = []
for i in range(n):
	(a, b) = (st[i][0], st[i][1])
	if i == 0:
		if a != 0:
			flag = False
		elif n == 1:
			if b < m:
				flag = False
		if flag:
			st2.append([a, b])
		else:
			break
	else:
		ch = False
		for j in range(len(st2)):
			(a1, b1) = (st2[j][0], st2[j][1])
			if b1 >= a:
				ch = True
		if ch:
			st2.append([a, b])
if flag:
	temp = False
	for i in range(len(st2)):
		(a, b) = (st[i][0], st[i][1])
		if b >= m:
			temp = True
			break
	if temp:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


def friends(m, lst1, lst2):
	if lst1[0] != 0:
		return 'NO'
	d = 0
	for i in range(len(lst1)):
		if lst1[i] <= d:
			d = max(d, lst2[i])
	if d >= m:
		return 'YES'
	return 'NO'
(n, m) = [int(j) for j in input().split()]
(a, b) = (list(), list())
for i in range(n):
	(s, t) = [int(x) for x in input().split()]
	a.append(s)
	b.append(t)
print(friends(m, a, b))


(n, m) = map(int, input().split())
l = [0] * m
for i in range(n):
	(x, y) = map(int, input().split())
	for i in range(x, y):
		l[i] = 1
if 0 in l:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
i = 1
ep = 0
st = 0
l = []
f = 0
for x in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
for x in l:
	a = x[0]
	b = x[1]
	if i == 1:
		if a != 0:
			f = 1
			print('NO')
			break
		i = 0
		if b >= m:
			f = 1
			print('YES')
			break
		ep = b
		continue
	if a > ep:
		f = 1
		print('NO')
		break
	else:
		ep = max(ep, b)
		if ep >= m:
			f = 1
			print('YES')
			break
if f == 0:
	print('NO')


(n, m) = [int(i) for i in input().split()]
s = set([0])
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	a1 = [i for i in range(a, b + 1)]
	if a1[0] in s:
		s.update(a1, s)
	else:
		s.update(a1[1:], s)
if s != set([int(i) for i in range(m + 1)]):
	print('NO')
else:
	print('YES')


R = lambda : map(int, input().split())
(n, m) = R()
pos = 0
for _ in range(n):
	(s, e) = R()
	if s > pos:
		break
	pos = max(e, pos)
print('YES' if pos >= m else 'NO')


x = input()
(n, m) = x.split()
n = int(n)
m = int(m)
visited = [0] * 105
visited[0] = 1
i = 0
while i < n:
	y = input()
	(a, b) = y.split()
	a = int(a)
	b = int(b)
	if visited[a] == 1:
		for j in range(a, b + 1):
			visited[j] = 1
	i += 1
if visited[m] == 1:
	print('YES')
else:
	print('NO')


[n, m] = [int(i) for i in input().split()]
a = []
for i in range(n):
	a.append([int(j) for j in input().split()])
a.sort()
b = [a[0]]
for i in a[1:]:
	if i[0] == b[-1][0]:
		b[-1] = i
	else:
		b.append(i)
x = 0
for i in b:
	if x < i[0]:
		break
	x = max(x, i[1])
if x == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
c = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if c > m - 1:
		print('YES')
		exit(0)
	elif c > a - 1:
		c = max(c, b)
	else:
		print('NO')
		exit(0)
if c > m - 1:
	print('YES')
else:
	print('NO')


n = [int(i) for i in input().split()]
x = 0
for i in range(n[0]):
	a = [int(j) for j in input().split()]
	if a[0] <= x and x != n[1]:
		x = max(x, a[1])
if x == n[1]:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
c = [False for i in range(m + 1)]
for i in range(n):
	(x, y) = list(map(int, input().split()))
	for j in range(x + 1, y + 1):
		c[j] = True
print('YES' if all(c[1:]) else 'NO')


nums = [int(x) for x in input().split()]
(n, m) = (nums[0], nums[1])
maxb = 0
for i in range(n):
	nums = [int(x) for x in input().split()]
	if nums[0] > maxb:
		break
	if nums[1] > maxb:
		maxb = nums[1]
if maxb >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
x = [False] * 101
for _ in range(n):
	(a, b) = map(int, input().split())
	for i in range(a, b):
		x[i] = True
for i in range(m):
	if not x[i]:
		print('NO')
		exit(0)
print('YES')


(n, m) = map(int, input().split())
arr = []
for _ in range(n):
	(a, b) = map(int, input().split())
	arr.append([a, b])
last = 0
for i in range(0, len(arr)):
	if last >= arr[i][0]:
		last = max(arr[i][1], last)
if last == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
rm = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a > rm:
		print('NO')
		exit()
	rm = max(rm, b)
if rm >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
teleports = []
for i in range(n):
	teleports.append(list(map(int, input().split())))
done = True
for i in range(0, m * 2 + 1):
	tdone = False
	for j in teleports:
		if j[0] <= i / 2 <= j[1]:
			tdone = True
			break
	if not tdone:
		done = False
		break
if done:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
cur = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	if x <= cur:
		cur = max(cur, y)
if cur >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
r = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a <= r <= b:
		r = b
if r == m:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
l = 0
r = 0
(a, b) = map(int, input().split())
l = a
r = b
for i in range(n - 1):
	(a, b) = map(int, input().split())
	if a <= r and a >= l:
		r = max(b, r)
if l <= m <= r and l == 0:
	print('YES')
else:
	print('NO')


arr = []
(n, m) = map(int, input().strip().split(' '))
for i in range(n):
	a = list(map(int, input().strip().split(' ')))
	arr.append(a)
lol = 0
ans = 1
for i in arr:
	if i[0] > lol:
		ans = -1
		break
	lol = max(lol, i[1])
if m > lol or ans == -1:
	print('NO')
else:
	print('YES')


(n, m) = list(map(int, input().split()))
t = sorted([list(map(int, input().split())) for _ in range(n)])
p = 0
for i in t:
	if i[0] <= p:
		if i[1] > p:
			p = i[1]
			if p >= m:
				print('YES')
				exit()
print('NO')


def solve():
	(n, m) = get([int])
	v = 0
	for _ in range(n):
		(a, b) = get([int])
		if a > v:
			continue
		v = max(b, v)
		if v >= m:
			return 'YES'
	else:
		return 'NO'
	return None
_testcases = '\n3 5\n0 2\n2 4\n3 5\n\nYES\n\n\n\n3 7\n0 4\n2 5\n6 7\n\nNO\n'.strip()
from bisect import bisect_left, bisect_right
from collections import defaultdict
from functools import lru_cache
from heapq import heapify, heappop, heappush
from operator import itemgetter, attrgetter
import bisect
import collections
import functools
import heapq
import itertools
import math
import operator
import re
import string
import sys
inf = float('inf')
cache = lru_cache(None)
sys.setrecursionlimit(10000)

def tree():
	return collections.defaultdict(tree)

def equal(x, y, epsilon=1e-06):
	if -epsilon <= x - y <= epsilon:
		return True
	if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:
		return False
	return -epsilon <= (x - y) / x <= epsilon or -epsilon <= (x - y) / y <= epsilon

def get(_type):
	if type(_type) == list:
		if len(_type) == 1:
			_type = _type[0]
			return list(map(_type, input().strip().split()))
		else:
			return [_type[i](inp) for (i, inp) in enumerate(input().strip().split())]
	else:
		return _type(input().strip())
printRecursionTree = timeit = lambda x: x
(_p, print) = (print, lambda *a, **b: None)
_p(solve())


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
a = sorted(a)
if a[0][0] > 0:
	print('NO')
else:
	maxTravel = 0
	short = False
	for i in a:
		if i[0] <= maxTravel:
			if i[1] > maxTravel:
				maxTravel = i[1]
		else:
			short = True
			break
	if short:
		print('NO')
	elif maxTravel >= m:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
mylist = []
for i in range(n):
	l = input()
	mylist.append(l)
last = 0
for i in range(n):
	(x1, y1) = map(int, mylist[i].split())
	if x1 <= last:
		last = max(y1, last)
if last >= m:
	print('YES')
else:
	print('NO')


import sys
for (i, line) in enumerate(sys.stdin.readlines()):
	if i == 0:
		(_, end_point) = tuple(map(lambda x: int(x), line.split()))
		end_point = int(end_point)
		tele_list = []
	else:
		tele_list.append(tuple(map(lambda x: int(x), line.split())))
pos = 0
for tele in tele_list:
	if tele[0] > pos:
		print('NO')
		exit()
	else:
		if pos >= end_point:
			print('YES')
			exit()
		if tele[1] < pos:
			continue
		else:
			pos = tele[1]
if pos >= end_point:
	print('YES')
	exit()
else:
	print('NO')
	exit()


(n, m) = map(int, input().split())
r = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x > r:
		print('NO')
		quit()
	r = max(r, y)
if m <= r:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = [0] * m
for i in range(n):
	(s, e) = map(int, input().split())
	for j in range(s, e):
		l[j] = 1
print('NO' if 0 in l else 'YES')


(n, l) = map(int, input().split())
locs = []
for i in range(n):
	locs.append(list(map(int, input().split())))
i = 0
for (j, loc) in enumerate(locs):
	if i >= loc[0] and i <= loc[1]:
		i = loc[1]
if i == l:
	print('YES')
else:
	print('NO')


def canReach(teleports, loc):
	(prevx, prevy) = teleports.pop(0)
	if len(teleports) == 0:
		if prevy >= loc and prevx == 0:
			print('YES')
		else:
			print('NO')
		return
	for (x, y) in teleports:
		if x <= prevy and y >= loc:
			print('YES')
			return
		elif x > prevy:
			print('NO')
			return
		elif prevy < y:
			prevy = y
	if prevy != loc:
		print('NO')
	elif prevy == loc:
		print('YES')

def main():
	(n, loc) = list(map(int, input().split()))
	teleports = []
	for i in range(n):
		teleports.append(tuple(map(int, input().split())))
	canReach(teleports, loc)
main()


import sys, collections
(n, m) = map(int, sys.stdin.readline().split())
arr = []
for _ in range(n):
	(a, b) = map(int, sys.stdin.readline().split())
	arr.append((a, b))
q = collections.deque()
check = [False] * 101
check[0] = True
q.append(0)
while q:
	x = q.popleft()
	for i in range(n):
		if arr[i][0] == x:
			for j in range(arr[i][0], arr[i][1] + 1):
				if not check[j] and j <= 100:
					check[j] = True
					q.append(j)
print('YES' if check[m] else 'NO')


(n, d) = map(int, input().split())
temp = [0] * (d + 1)
for i in range(n):
	(a, b) = map(int, input().split())
	for j in range(a, b):
		temp[j] += 1
flag = True
for i in range(d):
	if temp[i] == 0:
		flag = False
		break
if d == 0:
	flag = True
if flag:
	print('Yes')
else:
	print('No')


def sai():
	(n, d) = map(int, input().split())
	l = [0] * (d + 1)
	temp = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		l[x] += 1
		l[y] += -1
		if y == d:
			temp = 1
	a = 0
	for i in l[:-1]:
		a += i
		if a == 0:
			return 'NO'
	return 'Yes' if temp == 1 else 'NO'
print(sai())


import sys
sys.setrecursionlimit(1000000)
read = sys.stdin.readline
(n, m) = map(int, read().split())
cango = 0
for _ in range(n):
	(point, limit) = map(int, read().split())
	if cango >= point and limit > cango:
		cango = limit
if cango >= m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split(' ')))
l = [0 for i in range(101)]
for i in range(n):
	(a, b) = list(map(int, input().split(' ')))
	for j in range(a, b):
		l[j] = 1
f = 0
for i in range(m):
	if l[i] != 1:
		f = 1
		print('NO')
		break
if f == 0:
	print('YES')


(n, m) = map(int, input().split())
ar = [0] * m
for x in range(n):
	(a, b) = map(int, input().split())
	ar[a:b] = [1] * (b - a)
print('YES' if set(ar) == set([1]) else 'NO')


(teleports, location) = map(int, input().split())
(start, end) = map(int, input().split())
if start == 0:
	if end == location:
		print('YES')
		quit()
	for a in range(teleports - 1):
		(start1, end1) = map(int, input().split())
		if start1 <= end:
			if end1 == location:
				print('YES')
				break
			if end1 > end:
				end = end1
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
x = list()
x.append(0)
for i in range(0, n):
	s = list(map(int, input().split()))
	if s[0] in x:
		for j in range(s[0], s[1] + 1):
			if j in x:
				continue
			x.append(j)
if m in x:
	print('YES')
else:
	print('NO')


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

def f():
	global n, m
	x = L[0]
	mx = x[1]
	mi = x[0]
	for i in range(len(L)):
		if L[i][0] <= mx and L[i][1] > mx:
			mx = L[i][1]
		if L[i][0] <= mi:
			mi = L[i][0]
	return mx >= m and mi == 0
if f():
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [i for i in range(n + 1)]
b = [i for i in range(n + 1)]
for i in range(n):
	(a[i], b[i]) = map(int, input().split())
for i in range(m):
	can = False
	for j in range(n):
		if i >= a[j] and i <= b[j] and (i + 1 >= a[j]) and (i + 1 <= b[j]):
			can = True
	if can == False:
		print('NO')
		exit(0)
print('YES')


(n, m) = input().split()
n = int(n)
m = int(m)
bReak = False
for i in range(n):
	(start, stop) = input().split()
	start = int(start)
	stop = int(stop)
	if i == 0:
		if start != 0:
			bReak = True
		maxtp = stop
	elif start <= maxtp:
		if stop > maxtp:
			maxtp = stop
if maxtp >= m and bReak == False:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
d = 102 * [False]
d[0] = True
for t in range(n):
	(a, b) = map(int, input().split())
	if d[a] == True:
		for i in range(a, b + 1):
			d[i] = True
if False in d[0:m + 1]:
	print('NO')
else:
	print('YES')


I = lambda : map(int, input().split())
(n, m) = I()
reach = 0
maxx = 0
for i in range(n):
	(x, y) = I()
	if x > maxx:
		break
	maxx = max(maxx, y)
if maxx >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
f = [0] * m
for _ in range(n):
	(a, b) = map(int, input().split())
	f[a:b] = [1] * (b - a)
print('YES' if f.count(1) == m else 'NO')


def main():
	ok = True
	(n, m) = map(int, input().split())
	maxi = 0
	for _ in range(n):
		(a, b) = map(int, input().split())
		if a > maxi:
			ok = False
			break
		maxi = max(maxi, b)
	if maxi < m:
		ok = False
	print('YES' if ok else 'NO')
main()


(n, m) = map(int, input().split())
end = 0
flag = True
for i in range(n):
	(s, e) = map(int, input().split())
	if i == 0:
		if s > 0:
			flag = False
			break
		end = e
	if end < s:
		flag = False
		break
	end = max(e, end)
print('YES' if flag and end == m else 'NO')


(n, m) = map(int, input().split())
a = [0] * (m + 1)
for _ in range(n):
	(x, y) = map(int, input().split())
	for i in range(x, y):
		a[i] = 1
flag = 0
for i in range(m):
	if a[i] == 0:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')


(n, m) = [int(i) for i in input().split()]
A = []
for i in range(n):
	a = [int(i) for i in input().split()]
	A.append(a)
A.sort()
if A[0][0] != 0:
	print('NO')
else:
	max_r = A[0][1]
	for i in range(1, len(A)):
		if A[i][0] <= max_r:
			max_r = max(max_r, A[i][1])
	if m <= max_r:
		print('YES')
	else:
		print('NO')


(n, m) = (int(i) for i in input().split())
coo = set()
for i in range(n):
	cur = [int(i) for i in input().split()]
	coo.update(set(range(cur[0] + 1, cur[1] + 1)))
br = 0
for i in range(1, m + 1):
	if i not in coo:
		br = 1
		break
if not br:
	print('YES')
else:
	print('NO')


a = input().split()
a = list(map(int, a))
(n, m) = (a[0], a[1])
list1 = []
for i in range(0, n):
	a = input().split()
	a = list(map(int, a))
	list1.append(a)
if list1[0][0] != 0:
	print('NO')
else:
	list2 = [0]
	for i in range(0, n):
		if list1[i][0] in list2:
			for each in range(list1[i][0], list1[i][1] + 1):
				list2.append(each)
	if m in list2:
		print('YES')
	else:
		print('NO')


(n, m) = [int(j) for j in input().split()]
(src, dst) = [int(j) for j in input().split()]
if src == 0:
	canGo = dst
	for i in range(n - 1):
		(src, dst) = [int(j) for j in input().split()]
		if src <= canGo:
			canGo = max(canGo, dst)
	if canGo >= m:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
s = []
for i in range(n):
	s.append(list(map(int, input().split())))
r = 0
s.sort()
for i in range(n):
	if s[i][0] <= r:
		r = max(r, s[i][1])
print('YES' if m <= r else 'NO')


(n, des) = [int(i) for i in input().strip().split(' ')]
l = []
s = set()
m = 10 ** 10
ma = 0
for _ in range(n):
	(a, b) = [int(i) for i in input().strip().split(' ')]
	m = min(m, a, b)
	ma = max(ma, b)
	l.append([i for i in range(a, b + 1)])
if m != 0:
	print('NO')
elif len(l) == 1:
	print('YES' if des in l[0] else 'NO')
else:
	s = set(l[0])
	pos = True
	for i in l:
		if len(s.intersection(i)) > 0:
			s = s.union(i)
		else:
			pos = False
			break
	print('YES' if pos and ma == des else 'NO')


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
(t, final) = ei()
far = 0
for _ in range(t):
	(a, b) = ei()
	if a <= far:
		far = max(far, b)
print('NO' if far < final else 'YES')


(n, d) = map(int, input().split())
arr = []
for _ in range(n):
	r = list(map(int, input().split()))
	arr.append(r)
st = arr[0][1]
flag = True
j = 0
if arr[0][0] > 0:
	flag = False
while st < d:
	while arr[j][1] < st:
		if j >= n - 1:
			flag = False
			break
		j += 1
	if arr[j][0] <= st and arr[j][1] >= st:
		st = arr[j][1]
		j += 1
	else:
		flag = False
		break
	if st >= d:
		break
	if j >= n and st < d:
		flag = False
		break
if flag:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
(s, e) = map(int, input().split())
f = True
nxt = e
if s != 0:
	f = False
for i in range(n - 1):
	(s, e) = map(int, input().split())
	if s <= nxt:
		nxt = max(nxt, e)
	else:
		f = False
print('YES' if f and m <= nxt else 'NO')


(n, m) = map(int, input().split())
ch = True
(x, y) = map(int, input().split())
p = y
if x != 0:
	ch = False
for i in range(n - 1):
	(x, y) = map(int, input().split())
	if x > p:
		ch = False
	p = max(p, y)
if m > p:
	ch = False
print('YES' if ch else 'NO')


(t, x) = map(int, input().split())
lst = []
for c in range(t):
	lst.append(list(map(int, input().split())))
while x != 0:
	k = 0
	for c in range(0, t):
		if x in range(lst[c][0], lst[c][1] + 1):
			t = c
			k = 1
			x = lst[c][0]
			break
	if k != 1:
		print('NO')
		exit(0)
print('YES')


(n, m) = map(int, input().split())
t = []
for i in range(n):
	t = t + list(map(int, input().split()))
if not t[0] == 0:
	print('NO')
else:
	des = t[1]
	for i in range(1, 2 * n, 2):
		if i == 2 * n - 1 and des < m:
			print('NO')
			break
		if des >= m:
			print('YES')
			break
		elif des < t[i + 1]:
			print('NO')
			break
		if des < t[i + 2]:
			des = t[i + 2]


(n, m) = map(int, input().split())
r = 0
while n:
	(a, b) = map(int, input().split())
	if a > r:
		break
	r = max(r, b)
	n -= 1
print('YNEOS'[r < m::2])


(n, m) = map(int, input().split())
b = []
(left, right) = list(map(int, input().split()))
if left == 0:
	for i in range(n - 1):
		temp = list(map(int, input().split()))
		if temp[0] <= right:
			if temp[1] > right:
				right = temp[1]
	if right >= m:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [[int(i) for i in input().split()] for i in range(n)]
a.sort()
v = [False for i in range(n)]
ans = 'NO'
if a[0][0] == 0:
	v[0] = True
for i in range(n):
	if v[i] == False:
		continue
	j = i + 1
	while j < n:
		if a[i][1] < a[j][0]:
			break
		v[j] = True
		j += 1
	if a[i][1] >= m:
		ans = 'YES'
print(ans)


import sys
(n, m) = [int(x) for x in input().split()]
points = []
for _ in range(n):
	(a, b) = [int(x) for x in input().split()]
	points.append((b, a))
reach = m
points.sort(reverse=True)
for (b, a) in points:
	if a <= reach <= b:
		reach = min(a, reach)
if reach == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ma = 0
flag = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if flag == 1:
		continue
	if x > ma:
		flag = 1
	ma = max(ma, y)
	i += 1
if flag == 1:
	print('NO')
elif ma < m:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
i = 0
c = 0
d = 1
list1 = []
list2 = []
Range = int()
while i < n:
	c += 1
	(h, e) = map(int, input().split())
	i += 1
	list1.append(h)
	list2.append(e)
if max(list2) >= m:
	if list1[0] == 0:
		Range = list2[d - 1]
		while d <= n:
			if Range >= m:
				print('yes')
				exit(0)
			elif Range >= list1[d] and Range <= list2[d]:
				Range = list2[d]
				d += 1
			elif Range >= list1[d] and Range >= list2[d]:
				d += 1
			else:
				print('no')
				exit(0)
	else:
		print('No')
else:
	print('No')


import sys
line1 = sys.stdin.readline()
(n, m) = [int(x) for x in line1.split(' ')]
edges = [0] * m
for i in range(n):
	line = sys.stdin.readline()
	(x, y) = [int(x) for x in line.split(' ')]
	if x == y:
		continue
	for j in range(x, y):
		edges[j] = 1
if sum(edges) == len(edges):
	print('YES')
else:
	print('NO')


def read():
	return tuple((int(x) for x in input().split()))

def main():
	(n, m) = read()
	l = []
	for i in range(m + 1):
		l.append([False] * (m + 1))
		l[i][i] = True
	for i in range(n):
		(a, b) = read()
		for j in range(a + 1):
			for k in range(a, b + 1):
				l[j][k] = l[j][a]
	return l[0][m]
if main():
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
arr = []
start = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a <= start:
		start = max(start, b)
if start < m:
	print('NO')
else:
	print('YES')


import sys
(n, m) = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
last = 0
for i in range(n):
	if a[i][0] <= last:
		last = max(last, a[i][1])
if last >= m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
l = [0] * (m + 1)
l[0] = 1
for i in range(n):
	(a, b) = list(map(int, input().split()))
	for i in range(a + 1, b + 1):
		l[i] = 1
if 0 in l:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
d = 0
l = []
for i in range(n):
	(x, y) = map(int, input().split())
	l.append([x, y])
if l[0][0] != 0:
	print('NO')
	exit()
if m >= l[0][0] and m <= l[0][1]:
	print('YES')
	exit()
maxl = l[0][1]
for i in range(1, n):
	if l[i][0] > maxl:
		print('NO')
		exit()
	maxl = max(l[i][1], maxl)
	if m >= l[i][0] and m <= maxl:
		print('YES')
		exit()
print('NO')


MaxN = 128

def read():
	return [int(v) for v in input().split()]

def main():
	(n, m) = read()
	a = []
	for _ in range(n):
		a.append(read())
	a.sort(key=lambda v: v[0])
	highest_val = 0
	for (start, end) in a:
		if start > highest_val:
			print('NO')
			return
		highest_val = max(highest_val, end)
	if highest_val >= m:
		print('YES')
	else:
		print('NO')
main()


(n, m) = map(int, input().split())
l = [0] * 101
for _ in range(n):
	(a, b) = map(int, input().split())
	for i in range(a, b):
		l[i] = 1
mn = 1
for i in range(m):
	mn = min(mn, l[i])
print(['NO', 'YES'][mn])


IL = lambda : list(map(int, input().split()))
I = lambda : int(input())
(n, m) = IL()
ab = sorted([IL() for i in range(n)])
x = 0
for (a, b) in ab:
	if a <= x:
		x = max(x, b)
print('YES' if x >= m else 'NO')


(m, n) = list(map(int, input().split()))
store = []
for x in range(m):
	store.append(list(map(int, input().split())))
maxnum = temp = store[0][1]
for x in store:
	if x[0] <= temp:
		temp = x[1] if temp < x[1] else temp
		maxnum = maxnum if maxnum > temp else temp
	else:
		break
if maxnum >= n and store[0][0] == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
(a, b) = map(int, input().split())
(aPre, bPre) = (a, b)
mx = b
for _ in range(n - 1):
	(a, b) = map(int, input().split())
	if a <= mx:
		mx = max(b, mx)
	if mx == m:
		print('YES')
		break
else:
	print('YES' if n == 1 and b == m and (a == 0) else 'NO')


(n, m) = map(int, input().split())
teleport = []
for i in range(n):
	teleport.append(list(map(int, input().split())))
ans = 'NO'
start = 0
for i in range(n):
	if start < teleport[i][0]:
		break
	start = max(start, teleport[i][1])
if start >= m:
	ans = 'YES'
print(ans)


ini_input = input()
ini_list = ini_input.split()
num = int(ini_list[0])
des = int(ini_list[1])
tele_list = []
cnt = 0
while cnt < num:
	cnt = cnt + 1
	tele = input()
	tele_list.append(tele.split())
tele_list.sort()
judge = 1
point = 0.5
while point <= des:
	cnt = 0
	num0 = 0
	while num0 < num:
		if point >= int(tele_list[num0][0]) and point <= int(tele_list[num0][1]):
			cnt = cnt + 1
		num0 = num0 + 1
	if cnt == 0:
		judge = 0
		break
	point = point + 1
if judge == 0:
	print('NO')
else:
	print('YES')


(n, m) = list(map(int, input().split()))
now = 0
(am, bm) = (0, 0)
(l, r) = (-100000, 0)
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if l <= a <= r:
		l = min(a, abs(l))
		r = max(b, r)
if l != 0:
	print('NO')
elif l <= m <= r:
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
setall = set([0])
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	s = set([i for i in range(a, b + 1)])
	if setall.intersection(s) != set({}):
		setall = setall.union(s)
if m in setall:
	print('YES')
else:
	print('NO')


n = list(input().split())
m = list(range(111))
for i in range(101):
	m[i] = 0
m[0] = 1
for i in range(int(n[0])):
	a = list(input().split())
	if m[int(a[0])] == 1:
		for j in range(int(a[1]) - int(a[0]) + 1):
			m[j + int(a[0])] = 1
if m[int(n[1])] == 1:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [0] * n
for i in range(n):
	a[i] = list(map(int, input().split()))
a.sort()
r = 0
while r < m:
	i = 0
	r1 = 0
	while i < n and a[i][0] <= r:
		r1 = max(r1, a[i][1])
		i += 1
	if r1 <= r:
		print('NO')
		exit()
	r = r1
print('YES')


l = list(map(int, input().split()))
le = 0
ri = 0
f = l[1]
n = l[0]
flag = 0
for i in range(l[0]):
	l = list(map(int, input().split()))
	if ri > l[1]:
		l[1] = ri
	le = l[0]
	if le > ri:
		flag = 1
		break
	ri = l[1]
if ri == f and flag == 0:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
m1 = 0
for i in range(n):
	if a[i][0] <= m1 and a[i][1] >= m1:
		m1 = a[i][1]
if m1 >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
tp = sorted([list(map(int, input().split())) for _ in range(n)])
if tp[0][0] != 0:
	print('NO')
else:
	right = tp[0][1]
	for i in range(1, n):
		if tp[i][0] <= right < tp[i][1]:
			right = tp[i][1]
		elif tp[i][0] > right:
			print('NO')
			break
	else:
		print('YES' if right >= m else 'NO')


def canToEnd(intervals, end_index):
	intervals.sort(key=lambda x: x.start)
	n = len(intervals)
	end = 0
	for inter in intervals:
		if inter.start <= end:
			end = max(end, inter.end)
		else:
			return False
	if end >= end_index:
		return True
	return False

class Interval:

	def __init__(self, s=0, e=0):
		self.start = s
		self.end = e
(n, m) = [int(a) for a in input().strip().split()]
intervals = []
for i in range(n):
	(start, end) = [int(a) for a in input().strip().split()]
	intervals.append(Interval(start, end))
if canToEnd(intervals, m):
	print('YES')
else:
	print('NO')


(i, j) = map(int, input().split())
(x, y) = map(int, input().split())
ans = True
c = y
if x > 0:
	ans = False
for g in range(i - 1):
	(x, y) = map(int, input().split())
	if x > c:
		if c < j:
			ans = False
	c = max(c, y)
if c < j:
	ans = False
if ans:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = [0] * m + [0]
for i in range(n):
	(x1, x2) = map(int, input().split())
	for i in range(x1, x2):
		a[i] = 2
	if a[x2] != 2:
		a[x2] = 1
a.pop()
if 0 in a or 1 in a:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
i = 1
t = 0
while i <= n:
	(a, b) = map(int, input().split())
	if t < a:
		break
	t = max(t, b)
	i += 1
if t == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
e = set()
a = 1
b = 0
for i in range(n):
	(a1, b1) = map(int, input().split())
	if a1 <= b:
		if b <= b1:
			b = b1
	if a1 <= a:
		a = a1
if a == 0 and b == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
d = [0] * (m + 1)
(a, b) = map(int, input().split())
for j in range(a, b + 1):
	d[j] = 1
for i in range(n - 1):
	(a, b) = map(int, input().split())
	for j in range(a + 1, b + 1):
		d[j] = 1
for i in range(0, m + 1):
	if d[i] == 0:
		print('NO')
		break
else:
	print('YES')


(n, m) = [int(z) for z in input().split()]
cur = 0
for i in range(n):
	(l, r) = [int(z) for z in input().split()]
	if l <= cur <= r:
		cur = r
	if l <= m <= cur:
		print('YES')
		return
print('NO')


inp = input()
(N, M) = inp.split(' ')
N = int(N)
M = int(M)
tele = []
for i in range(N):
	inp = input().split(' ')
	inp[0] = int(inp[0])
	inp[1] = int(inp[1])
	tele.append(inp)
end = tele[0][1]
for i in range(N):
	if tele[i][0] <= end and tele[i][1] >= end:
		end = tele[i][1]
	if tele[i][0] > end:
		break
if M <= end:
	check = True
else:
	check = False
if tele[0][0] > 0:
	check = False
if tele[0][0] > M:
	check = False
if check:
	print('YES')
else:
	print('NO')


(n, k) = map(int, input().split())
lst = []
for x in range(n):
	(a, b) = map(int, input().split())
	lst.append((a, b))
lst.sort()
rs = 0
for (a, b) in lst:
	if a <= rs and b > rs:
		rs = b
if rs == k:
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
(l, r) = [int(i) for i in input().split()]
if l != 0:
	print('NO')
	exit()
n -= 1
for i in range(n):
	(l1, r1) = [int(i) for i in input().split()]
	if l1 <= r:
		r = max(r, r1)
print('YES') if r >= m else print('NO')


R = lambda : map(int, input().split())
(n, m) = R()
e = 0
for _ in range(n):
	(a, b) = R()
	if a <= e:
		e = max(e, b)
print('NO' if e < m else 'YES')


def get_data():
	(n, k) = list(map(int, input().split(' ')))
	data = [[n, k]]
	for i in range(n):
		(i1, i2) = list(map(int, input().split(' ')))
		data.append([i1, i2])
	return data

def test2():
	data = get_data()
	(n, k) = data[0]
	points = data[1:]
	flag = 0
	for (a1, a2) in points:
		if flag >= a1:
			flag = max(flag, a2)
	if flag >= k:
		return 'yes'
	else:
		return 'no'
res = test2()
print(res)


(n, m) = map(int, input().split())
ans = True
a = {}
d = 0
for i in range(n):
	(x, y) = map(int, input().split())
	d = max(d, y)
	if x in a:
		a[x] = max(a[x], d)
	else:
		a[x] = d
k = list(a.keys())
k.sort()
for i in range(len(k)):
	if i == 0:
		if k[i] == 0:
			continue
		else:
			ans = False
			break
	elif k[i] <= a[k[i - 1]]:
		continue
	else:
		ans = False
		break
if ans:
	if m <= a[k[-1]]:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


accessible = [False] * 120
(n, m) = map(int, input().split())
for temp in range(n):
	(x, y) = map(int, input().split())
	accessible[x + 1:y + 1] = [True] * (y - x)
for current_location in range(1, m + 1):
	if not accessible[current_location]:
		print('NO')
		exit()
	else:
		pass
print('YES')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
cnt = b[0]
for i in range(n - 1):
	if cnt >= a[i + 1]:
		cnt = max(b[i + 1], cnt)
if cnt >= m and a[0] == 0:
	print('YES')
else:
	print('NO')


def main():
	l1 = list(map(int, input().split()))
	target = l1[1]
	L = []
	for i in range(l1[0]):
		L.append(list(map(int, input().split())))
	MAX = maxteleportrange(L[0], L)
	if target <= MAX and L[0][0] == 0:
		print('YES')
	else:
		print('NO')

def maxteleportrange(candidate, L):
	maxi = candidate[1]
	for teleport in L:
		if teleport[0] >= candidate[0] and teleport[0] <= candidate[1] and (teleport[1] > candidate[1]) and (maxi <= teleport[1]):
			maxi = teleport[1]
	if maxi != candidate[1]:
		return maxteleportrange(L[[teleport[1] for teleport in L].index(maxi)], L)
	else:
		return candidate[1]
main()


(n, m) = input().split(' ')
n = int(n)
m = int(m)
c = []
for i in range(0, n):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	c.append([a, b])
c.sort()
s = 2
hh = 1
a1 = c[0][0]
if a1 != 0:
	hh = 0
a2 = c[0][1]
for i in range(1, n):
	if c[i][0] <= a2 and c[i][1] >= a2:
		a2 = c[i][1]
	elif c[i][0] > a2:
		break
if a2 >= m:
	s = 1
s = s * hh
if s == 1:
	print('YES')
else:
	print('NO')


from collections import Counter, deque

def lInt(d=None):
	return map(int, input().split(d))
(n, m, *_) = lInt()
a = []
for i in range(n):
	(x, y, *_) = lInt()
	a.append((x, y))
a.sort()
r = 0
for (i, t) in enumerate(a):
	if r >= t[0]:
		r = max(r, t[1])
if r >= m:
	print('YES')
else:
	print('NO')


from collections import *
import sys
import math
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())

def stli():
	return [int(i) for i in input().rstrip('\n')]
(n, m) = li()
l = []
for i in range(n):
	l.append(li())
l.sort()
vis = [0 for i in range(1000)]
vis[0] = 1
for i in range(n):
	if not vis[l[i][0]]:
		break
	for j in range(l[i][0], l[i][1] + 1):
		vis[j] = 1
print('YES' if vis[m] else 'NO')


(n, m) = list(map(int, input().split()))
s = []
for i in range(n):
	(a, b) = list(map(int, input().split()))
	s += list(range(a, b))
	if b == m:
		s.append(b)
	s = list(set(s))
s = [x for x in s if x <= m]
if len(s) == m + 1 and min(s) == 0 and (max(s) == m):
	print('YES')
else:
	print('NO')


axis = [0] * 101
(m, n) = map(int, input().split())
for i in range(m):
	(x, y) = map(int, input().split())
	axis[x + 1:y + 1] = [1] * (y - x)
if all(axis[1:n + 1]):
	print('Yes')
else:
	print('No')


(n, m) = [int(i) for i in input().split()]
l = []
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	l.append([i for i in range(a, b + 1)])
list = []
for i in l:
	line = ' '.join((str(j) for j in i))
	list.append(line)
way = ''
for i in list:
	way = way + i + 'a'
k = 1
a = 0
b = 1
while b < m + 1:
	route = str(a) + ' ' + str(b)
	if way.find(route) != -1:
		a += 1
		b += 1
	else:
		k = 0
		break
if k == 0:
	print('NO')
else:
	print('YES')


import sys
(n, m) = input().strip().split(' ')
(n, m) = [int(n), int(m)]
check = [0] * 10000
cnt = 0
for i in range(n):
	(a, b) = input().strip().split(' ')
	(a, b) = [int(a), int(b)]
	if check[a] == 0:
		cnt += 1
		for j in range(a, b + 1):
			check[j] = cnt
	else:
		for j in range(a, b + 1):
			check[j] = cnt
if check[m] != check[0]:
	print('NO')
else:
	print('YES')


(n, m) = input().split()
n = int(n)
m = int(m)
(ag, bg) = input().split()
ag = int(ag)
bg = int(bg)
if ag != 0:
	print('No')
	exit()
if bg >= m:
	print('YES')
	exit()
for i in range(n - 1):
	(a, g) = input().split()
	a = int(a)
	b = int(g)
	if a <= bg:
		bg = max(b, bg)
	if bg >= m:
		print('Yes')
		exit()
if bg >= m:
	print('YES')
	exit()
print('NO')


(n, m) = map(int, input().split())
d = []
for i in range(n):
	d.append(list(map(int, input().split())))
k = 0
for i in d:
	if i[0] <= k:
		k = max(k, i[1])
if k >= m:
	print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
a = []
for i in range(n):
	a.append([int(i) for i in input().split()])
p = 0
t = True
for i in a:
	if p >= i[0]:
		p = max(i[1], p)
	else:
		t = False
if t == True and p >= m:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
ans = False
(p, q) = list(map(int, input().split()))
if p == 0:
	if n > 1:
		for i in range(n - 1):
			(a, b) = list(map(int, input().split()))
			if a <= q:
				p = a
				q = max(b, q)
				if q >= m:
					ans = True
					break
			else:
				break
	elif p <= m and m <= q:
		ans = True
if ans:
	print('YES')
else:
	print('NO')


(n, m) = list(map(int, input().split()))
ox = list(map(int, input().split()))
if ox[0] != 0:
	print('NO')
else:
	for i in range(n - 1):
		nx = list(map(int, input().split()))
		if nx[0] in range(ox[0], ox[1] + 1):
			if set(range(nx[0], nx[1] + 1)).issubset(set(range(ox[0], ox[1] + 1))) == False:
				ox = nx
	if m in range(ox[0], ox[1] + 1):
		print('YES')
	else:
		print('NO')


(n, m) = input().split()
(n, m) = (int(n), int(m))
y = 1
for i in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if i == 0:
		x = b
	else:
		if a > x:
			print('NO')
			exit()
		x = max(x, b)
	y = min(y, a)
if x >= m and y == 0:
	print('YES')
else:
	print('NO')


a_b = input().split()
a = int(a_b[0])
b = int(a_b[1])
l1 = []
l2 = []
c = 0
for i in range(a):
	c_d = input().split()
	l1.append(int(c_d[0]))
	l2.append(int(c_d[1]))
if b in l2:
	d = l1[l2.index(b)]
	for i in range(a):
		for i in range(a):
			if l1[i] < d <= l2[i]:
				d = l1[i]
				break
	if d == 0:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


(n, m) = map(int, input().split())
tel = []
for i in range(n):
	(tel1, tel2) = map(int, input().split())
	tel.append((tel1, tel2))
allpath = True
for i in range(m + 1):
	way = False
	for j in range(n):
		if tel[j][0] <= i and (tel[j][1] > i or tel[j][1] == m):
			way = True
			break
	if way == False:
		allpath = False
		break
if allpath == False:
	print('NO')
else:
	print('YES')


def main():
	str = input().split()
	n = eval(str[0])
	m = eval(str[1])
	flag = 1
	Max = 0
	for i in range(1, n + 1):
		str = input().split()
		l = eval(str[0])
		r = eval(str[1])
		if l > Max:
			flag = 0
		if flag == 0:
			continue
		Max = max(Max, r)
	if flag == 1 and Max < m:
		flag = 0
	if flag == 0:
		print('NO\n')
	else:
		print('YES\n')
main()


def fn(n):
	a = 0
	for i in range(int(n[0])):
		t = input().split(' ')
		if int(t[0]) <= a:
			a = max(a, int(t[1]))
	if a >= int(n[1]):
		return 'YES'
	else:
		return 'NO'
print(fn(input().split(' ')))


(n, m) = map(int, input().split())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append([a, b])
l.sort()
if l[0][0] != 0:
	print('NO')
else:
	x = l[0][1]
	flag = 0
	for i in range(n - 1):
		if l[i + 1][0] <= x:
			x = max(x, l[i + 1][1])
		else:
			flag = -1
			break
	if flag == -1 or x < m:
		print('NO')
	else:
		print('YES')


(n, m) = list(map(int, input().split()))
al = [None] * m
for i in range(n):
	(a, b) = list(map(int, input().split()))
	for j in range(a, b):
		al[j] = 1
g = True
for i in range(m):
	if al[i] is None:
		print('NO')
		g = False
		break
if g:
	print('YES')


import datetime
(n, m) = map(int, input().split())
starting = []
ending = []
for i in range(n):
	(x, y) = map(int, input().split())
	starting.append(x)
	ending.append(y)
if starting[0] > 0:
	print('NO')
else:
	current = ending[0]
	for i in range(1, n):
		if current >= m:
			print('YES')
			break
		elif starting[i] <= current <= ending[i]:
			current = ending[i]
		else:
			continue
	else:
		if current >= m:
			print('YES')
		else:
			print('NO')


(n, m) = map(int, input().split())
(cur, mx) = (0, 0)
for _ in range(n):
	(a, b) = map(int, input().split())
	if a <= cur:
		mx = max(mx, b)
	cur = mx
if cur >= m:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		a.append(tuple(map(int, input().split())))
	fg = False
	if not a[0][0]:
		r = a[0][1]
		for i in range(1, n):
			if r >= a[i][0]:
				r = max(r, a[i][1])
		if r >= m:
			fg = True
	print('YES' if fg else 'NO')
main()


(n, m) = [int(i) for i in input().split()]
a = 100 * [0]
a.append(0)
a[0] = 1
for i in range(n):
	(a1, b1) = [int(i) for i in input().split()]
	if a[a1] == 1:
		for j in range(a1, b1 + 1):
			a[j] = 1
if a[m] == 1:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	hi = 0
	for _ in range(n):
		(a, b) = map(int, input().split())
		if hi < a:
			break
		elif hi < b:
			hi = b
	print(('YES', 'NO')[hi < m])
main()


from collections import defaultdict
(n, m) = map(int, input().split())
g = defaultdict(set)
lis = []
for i in range(n):
	lis.append(list(map(int, input().split())))
lis.sort(key=lambda x: (x[0], x[1]))
for i in lis:
	for j in range(i[0] + 1, i[1] + 1):
		g[i[0]].add(j)
vis = [0] * (m + 1)
vis[0] = 1
st = [0]
while st:
	x = st[-1]
	for i in g[x]:
		if i == m:
			print('YES')
			exit()
		if vis[i] == 0:
			vis[i] = 1
			st.append(i)
			break
	else:
		st.pop()
print('NO')


(n, m) = map(int, input().split())
maxRight = 0
for _ in range(n):
	(a, b) = map(int, input().split())
	if a > maxRight:
		break
	maxRight = max(maxRight, b)
if maxRight >= m:
	print('YES')
else:
	print('NO')


import sys
(n, m) = input().split()
(n, m) = (int(n), int(m))
last = 0
for n_i in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if a > last:
		print('NO')
		sys.exit(0)
	last = max(last, b)
if last >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	(l, r) = map(int, input().split())
	a.append((l, 0))
	a.append((r, 1))
a.sort()
ok = True
first = True
cnt = 0
for ev in a:
	if first:
		first = False
		if ev[0] != 0:
			ok = False
			break
	if ev[1] == 0:
		cnt += 1
	else:
		cnt -= 1
		if cnt == 0 and ev[0] != m:
			ok = False
print('YES' if ok else 'NO')


input1 = input().split()
n = int(input1[0])
m = int(input1[1])
set = set()
lst = [0] * m
for i in range(n):
	tokens = input().split()
	ai = int(tokens[0])
	bi = int(tokens[1])
	for j in range(ai, bi):
		lst[j] = 1
if 0 in lst:
	print('NO')
else:
	print('YES')


(n, m) = map(int, input().split())
flag = 'YES'
min = 200
flag2 = 0
flag3 = 0
w = 0
for q in range(0, n):
	(a, b) = map(int, input().split())
	if flag3 == 0 and a == 0:
		flag3 = 1
		w = 0
	if flag3 == 1:
		if a > min:
			flag = 'NO'
			break
		if b >= m:
			flag2 = 1
			break
		if w == 0:
			w = 1
			min = b
		if min <= b:
			min = b
if flag2 == 0:
	flag = 'NO'
print(flag)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	(x1, x2) = map(int, input().split())
	a.append([x1, x2])
z = 0
zb = a[0][1]
for i in range(n):
	if a[i][0] <= z and m > zb and (i < n - 1) and (a[i + 1][0] <= zb) and (a[i + 1][1] >= zb):
		z = a[i + 1][0]
		zb = a[i + 1][1]
	elif a[i][0] <= z and m > zb and (i < n - 1) and (a[i + 1][0] <= zb) and (a[i + 1][1] < zb):
		z = zb
	elif a[i][0] == z and m <= zb:
		z = m
		break
	elif a[i][0] > z and i < n - 1 and (a[i + 1][0] > zb):
		break
	elif i == n - 1 and m <= zb and (z == a[i][0]):
		z = m
if z == m:
	print('YES')
else:
	print('NO')


def solve(n, m, lis):
	dis = 0
	if dis < listInput[0][0]:
		print('NO')
		return
	for i in range(n):
		dis = max(dis, listInput[i][1])
		if dis >= m:
			print('Yes')
			return
		if i < n - 1 and dis < listInput[i + 1][0]:
			break
	print('NO')
	return
(n, m) = map(int, input().split())
listInput = [list(map(int, input().split())) for i in range(n)]
solve(n, m, listInput)


(n, m) = map(int, input().split())
t = [False] * m
for _ in range(n):
	(a, b) = map(int, input().split())
	for x in range(a, b):
		t[x] = True
print('NO' if False in t else 'YES')


s = input()
s = s.split()
n = int(s[0])
m = int(s[1])
res = True
x = []
x.append(0)
for i in range(n):
	s = input()
	s = s.split()
	if int(s[0]) in x:
		for j in range(int(s[0]), int(s[1]) + 1):
			if j not in x:
				x.append(j)
if len(x) == m + 1:
	print('YES')
else:
	print('NO')


(N, M) = map(int, input().split())
l = 0
for _ in range(N):
	(x, y) = map(int, input().split())
	if l >= x:
		l = max(l, y)
	else:
		l = 0
		break
print('YES' if l >= M else 'NO')


(a, b) = map(int, input().split())
k = []
for i in range(a):
	k += [list(map(int, input().split()))]
k.sort()
if k[0][0] == 0:
	(x, y) = (k[0][0], k[0][1])
	l = 1
	for i in range(1, a):
		if k[i][0] > y:
			l = 0
			break
		if k[i][1] > y:
			y = k[i][1]
	if l == 0 or y < b:
		print('NO')
	else:
		print('YES')
else:
	print('NO')


(n, m) = [int(i) for i in input().split()]
a = []
b = []
m = 2 * m
for i in range(n):
	(a1, b1) = [int(i) for i in input().split()]
	a.append(2 * a1)
	b.append(2 * b1)
covered = [0] * 400
for i in range(n):
	for j in range(a[i], b[i] + 1):
		covered[j] = 1
flag = 0
for i in range(m + 1):
	if not covered[i]:
		flag = 1
if flag:
	print('NO')
else:
	print('YES')


def main():
	(N, M) = map(int, input().split())
	AB = tuple((tuple(map(int, input().split())) for _ in [0] * N))
	for i in range(M):
		for (a, b) in AB:
			if a <= i <= b and a <= i + 1 <= b:
				break
		else:
			print('NO')
			return
	print('YES')
main()


(t, n) = map(int, input().split())
travel = [0 for _ in range(n + 1)]
for _ in range(t):
	(a, b) = map(int, input().split())
	travel[a] = max(b, travel[a])
current = 0
max_dist = travel[0]
while max_dist > current and max_dist < n:
	current += 1
	max_dist = max(max_dist, travel[current])
print('YNEOS'[max_dist < n::2])


(n, z) = map(int, input().split())
m = []
for i in range(n):
	m.append(list(map(int, input().split())))
m.sort()
x = 0
for (a, b) in m:
	if a <= x:
		x = max(x, b)
	else:
		print('NO')
		break
else:
	if x >= z:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
t = [0] * 110
for a in range(n):
	(x, y) = map(int, input().split())
	t[x + 1:y + 1] = [1] * (y - x)
for i in range(1, m + 1):
	if t[i] != 1:
		print('No')
		exit(0)
print('Yes')


(n, m) = map(int, input().split())
t = []
for _ in range(n):
	(a, b) = map(int, input().split())
	t.append((a, b))
farthest_right_so_far = 0
for i in range(n):
	(l, r) = (t[i][0], t[i][1])
	if l > farthest_right_so_far:
		print('NO')
		exit()
	farthest_right_so_far = max(r, farthest_right_so_far)
	if farthest_right_so_far >= m:
		print('YES')
		exit()
print('NO')


(n, m) = map(int, input().split())
arr = []
flag = 0
for i in range(n):
	(x, y) = map(int, input().split())
	arr.append((x, y))
min1 = arr[0][0]
j = 0
max1 = arr[0][1]
for i in range(n):
	if i > 0:
		if arr[i][0] > max1:
			break
		else:
			max1 = max(max1, arr[i][1])
			j = i
if min1 != 0:
	print('NO')
elif min1 <= m <= max1:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
arr = [0] * (m + 1)
for _ in range(n):
	(a, b) = [int(x) for x in input().split()]
	arr[a] += 1
	arr[b] -= 1
ans = True
summ = 0
for i in range(m):
	summ += arr[i]
	if summ == 0:
		ans = False
		break
if ans:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
k = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if k >= x and k < y:
		k = y
if k >= m:
	print('YES')
else:
	print('NO')


values = list(map(int, input().split()))
n = values[0]
m = values[1]
point = 0
result = 'NO'
for i in range(n):
	teleport = list(map(int, input().split()))
	if point >= teleport[0]:
		if point < teleport[1]:
			point = teleport[1]
	else:
		break
	if point >= m:
		result = 'YES'
		break
print(result)


import sys
f = sys.stdin
(n, m) = f.readline().split()
n = int(n)
m = int(m)
reached = 0
failed = False
for _ in range(n):
	(a, b) = f.readline().split()
	a = int(a)
	b = int(b)
	if reached < a:
		failed = True
		break
	if reached < b:
		reached = b
if failed or m > reached:
	print('NO')
else:
	print('YES')


import math, fractions, collections
(n, m) = [int(x) for x in input().split()]
teleporter = [[int(x) for x in input().split()] for _ in range(n)]
flag = 0
next = 0
for i in range(n):
	curr = teleporter[i]
	if curr[0] > next:
		flag = 0
		break
	elif m <= curr[1]:
		flag = 1
		break
	next = max(next, curr[1])
print('YES' if flag else 'NO')


a = [int(q) for q in input().strip().split()]
t = 0
for k in range(a[0]):
	b = [int(q) for q in input().strip().split()]
	if k == 0:
		if b[0] != 0:
			t = 1
			break
		y = b[1]
		continue
	if b[0] <= y:
		if b[1] > y:
			y = b[1]
	else:
		t = 1
if t == 0 and y >= a[1]:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
p = 0
for i in range(0, n):
	(a1, b1) = map(int, input().split())
	if a1 <= p:
		p = max(b1, p)
if p == m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
ma = 0
for i in range(n):
	(a1, a2) = map(int, input().split())
	if ma >= a1:
		ma = max(ma, a2)
if ma >= m:
	print('YES')
else:
	print('NO')


axis = [0] * 101
(m, n) = map(int, input().split())
for i in range(m):
	(x, y) = map(int, input().split())
	axis[x + 1:y + 1] = [1] * (y - x)
for number in axis[1:n + 1]:
	if not number:
		print('No')
		exit(0)
print('Yes')


(n, m) = list(map(int, input().strip().split()))
vector = []
size = [0, 0]
for i in range(n):
	vector.append(list(map(int, input().strip().split())))
vector.sort()
count = 0
for i in vector:
	if size[1] < i[0]:
		break
	else:
		size[0] = min(size[0], i[0])
		size[1] = max(size[1], i[1])
		if size[0] <= m and size[1] >= m:
			count = 1
			break
if count == 1:
	print('YES')
else:
	print('NO')


import sys
(n, end) = input().split()
(n, end) = (int(n), int(end))
tp = []
for i in range(n):
	tp.append([int(j) for j in input().split()])
tp.append([end, end])
for _ in range(n):
	if tp[0][1] >= tp[1][0]:
		tp[0:2] = [[tp[0][0], max(tp[0][1], tp[1][1])]]
if tp == [[0, end]]:
	print('YES')
else:
	print('NO')


(n, k) = list(map(int, input().split()))
a = []
b = []
for _ in range(n):
	(na, nb) = list(map(int, input().split()))
	a.append(na)
	b.append(nb)
c = []
for (idx, el) in enumerate(a):
	c.append((el, 0, idx))
for (idx, el) in enumerate(b):
	c.append((el, 1, idx))
c = sorted(c, key=lambda x: (x[0], x[1]))
opened = set()
if c[0][0] == 0:
	opened.add(c[0][2])
	max_point = 0
	for el in c[1:]:
		if el[1] == 0 and len(opened) > 0:
			opened.add(el[2])
		elif el[1] == 1 and el[2] in opened:
			max_point = el[0]
			opened.remove(el[2])
	if max_point == k:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


import sys
lines = sys.stdin.read().splitlines()
result = [i.split() for i in lines]
while [] in result:
	result.remove([])
new_i = 0
if result != []:
	number = int(result[0][0])
	end = int(result[0][1])
	if int(result[1][0]) != 0:
		print('NO')
	else:
		for i in range(1, number + 1):
			if i == number:
				if int(result[number][1]) >= end:
					print('YES')
					exit()
				else:
					print('NO')
				exit()
			else:
				if int(result[i][1]) >= end:
					print('YES')
					exit()
				for j in range(i + 1, number + 1):
					if int(result[i][1]) >= int(result[j][0]) and int(result[j][1]) > int(result[i][1]):
						i = j
						if int(result[i][1]) >= end:
							print('YES')
							exit()
						if i == number:
							if int(result[i][1]) < end:
								print('NO')
								exit()
						elif int(result[i][1]) < int(result[i + 1][0]):
							print('NO')
							exit()
				if int(result[i][1]) < int(result[i + 1][0]):
					print('NO')
					exit()
else:
	print()


def o():
	return list(map(int, input().split()))
([n, m], r) = (o(), {})
for i in range(n):
	[a, b] = o()
	r[a] = max(b, r[a]) if a in r else b
w = [True if i == 0 else False for i in range(m + 1)]
for (i, a) in enumerate(w):
	if a == False:
		break
	if i in r:
		for j in range(i, r[i] + 1):
			w[j] = True
print('YES' if w[m] else 'NO')


(n, m) = map(int, input().split())
a = []
b = []
for i in range(n):
	(k, g) = map(int, input().split())
	a.append(k)
	b.append(g)
points_num = []
for i in range(m + 1):
	points_num.append(i)
points_precence_way = [0 for i in range(m)]
for i in range(n):
	for j in range(a[i], b[i]):
		points_precence_way[j] = 1
flag = True
for i in range(m):
	if points_precence_way[i] == 0:
		flag = False
		break
if flag:
	print('YES')
else:
	print('NO')


(n, m) = [int(x) for x in input().split()]
tps = []
for _ in range(n):
	tps.append(tuple([int(x) for x in input().split()]))
parts = [False for _ in range(m)]
for tp in tps:
	for i in range(tp[0], tp[1]):
		parts[i] = True
for p in parts:
	if not p:
		print('NO')
		break
else:
	print('YES')


from collections import OrderedDict
(NumOfTlps, POS) = [int(x) for x in input().split()]
(teleports, CurrPOS, tmpPOS) = (OrderedDict(), 0, 1)
for i in range(NumOfTlps):
	(tlpPOS, tlpLim) = [int(x) for x in input().split()]
	teleports.setdefault(tlpPOS, []).append(tlpLim)
if 0 not in teleports:
	print('NO')
else:
	while CurrPOS != POS:
		if tmpPOS == CurrPOS:
			break
		tmpPOS = CurrPOS
		if max(teleports[CurrPOS]) >= POS:
			CurrPOS = POS
		else:
			try:
				CurrPOS = max(filter(lambda x: x <= max(teleports[CurrPOS]) and x > CurrPOS, teleports.keys()), key=lambda x: teleports[x])
			except ValueError:
				CurrPOS = tmpPOS
	if CurrPOS == POS:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
q = [list(map(int, input().split())) for i in range(n)]
ok = True
mx_found = q[0][1]
mn_found = q[0][0]
for i in range(1, n):
	if q[i][0] > mx_found:
		ok = False
		break
	mx_found = max(mx_found, q[i][1])
print('YES' if ok and mn_found == 0 and (mx_found == m) else 'NO')


from sys import exit
(n, m) = map(int, input().split())
t = [-1 for i in range(101)]
for _ in range(n):
	(a, b) = map(int, input().split())
	t[a] = max(t[a], b)
cur = m
while True:
	beg = cur
	for (i, v) in enumerate(t):
		if cur <= v and cur >= i:
			if i == 0:
				print('Yes')
				exit(0)
			if i < beg:
				beg = i
	if beg == cur:
		print('No')
		exit(0)
	cur = beg


(n, m) = map(int, input().strip().split(' '))
l = [0]
f = 0
for i in range(n):
	(a, b) = map(int, input().strip().split(' '))
	if a <= l[0] and b >= m:
		print('YES')
		f = 1
		break
	elif a > l[0]:
		print('NO')
		f = 1
		break
	elif b > l[0]:
		l[0] = b
if f == 0:
	print('NO')


s = input()
(n, m) = list(map(int, s.split()))
port = []
for i in range(n):
	ss = input()
	p = list(map(int, ss.split()))
	port.append(p)
mar = 0
for each in port:
	if each[0] > mar:
		print('NO')
		exit()
	elif each[1] > mar:
		mar = each[1]
if mar >= m:
	print('YES')
else:
	print('NO')


def teleport():
	(n, m) = map(int, input().split())
	arr = [list(map(int, input().split())) for _ in range(n)][::-1]
	for e in arr:
		if e[0] > m:
			continue
		if m <= e[1]:
			m = e[0]
		else:
			continue
	if m <= 0:
		print('YES')
	else:
		print('NO')
teleport()


import sys
z = 0
n = 0
m = 0
x_max = 0
lines = []
for line in sys.stdin:
	line = line.rstrip('\r\n\t ').split(' ')
	if len(line) == 2:
		if z == 0:
			n = int(line[0])
			m = int(line[1])
			if m == 0:
				print('YES')
				exit()
			if n == 0:
				print('NO')
				exit()
		else:
			a = int(line[0])
			b = int(line[1])
			if a <= x_max < b:
				x_max = b
				if x_max >= m:
					print('YES')
					exit()
	z += 1
print('NO')


s = input()
a = s.split()
n = int(a[0])
m = int(a[1])
w = []
for h in range(m):
	w.append(h)
a = []
for i in range(n):
	x = input()
	b = x.split()
	b[0] = int(b[0])
	b[1] = int(b[1])
	a.append(b)
result = []
for i in a:
	for j in range(i[0], i[1]):
		if j not in result:
			result.append(j)
if result == w:
	print('YES')
else:
	print('NO')


(n, m) = [int(z) for z in input().split()]
dsf = 0
for _ in [0] * n:
	v = [int(z) for z in input().split()]
	if v[0] <= dsf:
		dsf = max(v[1], dsf)
	if dsf >= m:
		print('YES')
		exit(0)
if dsf >= m:
	print('YES')
else:
	print('NO')


def main():
	(n, m) = map(int, input().split())
	(s, e) = map(int, input().split())
	if s != 0:
		print('NO')
		return
	last_hop = e
	for i in range(n - 1):
		(s1, e1) = map(int, input().split())
		if s1 <= last_hop < e1:
			last_hop = e1
	if last_hop != m:
		print('NO')
		return
	print('YES')
main()


import math
import sys
import getpass
import bisect

def ria():
	return [int(i) for i in input().split()]

def gp(x1, y1, x2, y2, x3, y3):
	k = ((y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1)) / ((y2 - y1) ** 2 + (x2 - x1) ** 2)
	x4 = x3 - k * (y2 - y1)
	y4 = y3 + k * (x2 - x1)
	return (x4, y4)
files = True
if getpass.getuser().lower() == 'frohe' and files:
	sys.stdin = open('test.in')
(n, m) = ria()
ar = [0] * 400
st = [0] * 400
for i in range(n):
	(a, b) = ria()
	st[a] = 1
	for j in range(a + 1, b + 1):
		ar[j] = 1
if st[0] == 1 and sum(ar[1:m + 1]) == len(ar[1:m + 1]):
	print('YES')
else:
	print('NO')


some = input().split(' ')
n = int(some[0])
m = int(some[1])
y = 0
for i in range(n):
	some = input().split(' ')
	a = int(some[0])
	b = int(some[1])
	if y >= a:
		y = max(y, b)
if y >= m:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append(list(range(a, b + 1)))
for i in range(m):
	goon = True
	for j in range(n):
		if i in l[j] and i + 1 in l[j]:
			goon = False
			break
	if goon == True:
		print('NO')
		break
if goon == False:
	print('YES')


from sys import stdin as cin
from sys import stdout as cout

def main():
	(n, m) = map(int, cin.readline().split())
	a = [0] * n
	b = [0] * n
	for i in range(n):
		(a[i], b[i]) = map(int, cin.readline().split())
	q = 0
	if a[0] > 0:
		print('NO')
		return
	for i in range(n - 1):
		q = max(q, b[i])
		if q < a[i + 1]:
			print('NO')
			return
	q = max(q, b[n - 1])
	if q < m:
		print('NO')
		return
	print('YES')
main()


x = input().split()
tel = int(x[0])
target = int(x[1])
join = True
prev = 0
for i in range(tel):
	y = input().split()
	now = int(y[0])
	if now > prev:
		join = False
	if int(y[1]) > prev:
		prev = int(y[1])
if join == True and prev >= target:
	print('YES')
else:
	print('NO')


(n, m) = map(int, input().split())
dp = [0] * (m + 1)
t = [[int(i) for i in input().split()] for _ in range(n)]
dp[0] = 1
for i in t:
	if dp[i[0]]:
		for j in range(i[0] + 1, min(m + 1, i[1] + 1)):
			dp[j] = 1
print('YES' if dp[m] else 'NO')


(n, x) = [int(i) for i in input().split()]
aux = 0
for _ in range(n):
	(a, b) = [int(i) for i in input().split()]
	if aux >= a and b > aux and (b != a):
		aux = b
if aux >= x:
	print('YES')
else:
	print('NO')


(m, n) = map(int, input().split())
portNum = []
allNum = []
for k in range(0, n):
	allNum.append(k + 0.5)
for i in range(0, m):
	(a, b) = map(int, input().split())
	for j in range(a, b):
		portNum.append(j + 0.5)
allNumSet = set(allNum)
portNumSet = set(portNum)
if set.issubset(allNumSet, portNumSet):
	print('YES')
else:
	print('NO')


def solution():
	nm = [int(a) for a in input().split(' ')]
	dest = nm[1]
	n = nm[0]
	inp = []
	for l in range(n):
		ab = [int(a) for a in input().split(' ')]
		if len(ab) > 0:
			inp.append(ab)
	inp.sort(key=lambda x: x[0])
	if len(inp) == 0 or inp[0][0] > 0:
		print('NO')
		return
	global_max_reached = inp[0][1]
	for l in range(1, len(inp)):
		max_reached = float('-inf')
		for k in range(l):
			max_reached = max(max_reached, inp[k][-1])
		if max_reached < inp[l][0]:
			print('NO')
			return
		max_reached = max(max_reached, inp[l][-1])
		global_max_reached = max(max_reached, global_max_reached)
	if global_max_reached >= dest:
		print('YES')
		return
	else:
		print('NO')
		return
solution()


(n, m) = map(int, input().split())
vis = [0] * (m + 10)
vis[0] = 1
for i in range(n):
	(a, b) = map(int, input().split())
	if vis[a] == 1:
		for j in range(a, b + 1):
			vis[j] = 1
if vis[m]:
	print('YES')
else:
	print('NO')


l = input().split(' ')
(n, m) = (int(l[0]), int(l[1]))
v = []
for i in range(n):
	s = input().split(' ')
	v.append(s)
c = 'YES'
b = 0
i = 0
if int(v[0][0]) != 0:
	c = 'NO'
elif len(v) == 1:
	if int(v[0][1]) < m:
		c = 'NO'
	else:
		c = 'YES'
else:
	while 2 > 1:
		d = int(v[i][1])
		if int(v[i][1]) >= int(v[i + 1][0]) or b >= int(v[i + 1][0]):
			b = max(b, d)
		if b < int(v[i + 1][0]):
			c = 'NO'
			break
		if b > m or i == n - 2:
			break
		i += 1
if int(v[n - 1][1]) < m and b < m:
	c = 'NO'
print(c)