Teja likes cricket very much and likes to watch it all the time, but he is bored of watching the
matches alone and asks his friend to give him company. But his friend doesn’t know how to read
cricket scores so Teja decided to teach him. To make him understand better Teja gave him a list of
scores of an innings of a match. The scores are ordered in the increasing order of time at which it
was recorded.

In the version of Cricket Teja follows, runs can't be taken away from the batting team and a batsmen is not allowed to bat once he is dismissed, also the innings gets over when the 10th wicket falls or when the required number of overs are completed and no more scores are recorded once an innings get over.

Now Teja wants his friend to find out if its a valid score card or not. Since his friend
is busy watching football he asks for your help to answer Teja.

------ Input Format ------ 

- First line cointains an integer  N  denoting the number of scores recorded. 
- Next n line contain two integers Ri and Wi, Ri is the runs scored and Wi is the number of wickets
lost.

------ Output Format ------ 

print “YES” if it is valid else print “NO” without quotes.

------ Constraints ------ 

$1 ≤ N ≤ 10^{6}$
$0 ≤ Ri ≤ 10^{7}$
$0 ≤ Wi ≤ 10$

------ subtasks ------ 

30 points : $1 ≤ N ≤ 10^{4}$
70 points : $Original  Constraints$

----- Sample Input 1 ------ 
3
1 1
4 1
7 6
----- Sample Output 1 ------ 
YES
----- explanation 1 ------ 

----- Sample Input 2 ------ 
3
1 1
9 1
7 6
----- Sample Output 2 ------ 
NO
----- explanation 2 ------

Difficulty: EASY

Starter code:

Solutions:
n = int(input())
(c, d) = (0, 0)
for ni in range(n):
	(a, b) = map(int, input().split())
	if d >= 10:
		print('NO')
		break
	elif a >= c and b >= d:
		c = a
		d = b
	else:
		print('NO')
		break
else:
	print('YES')


a = b = 0
N = int(input())
for i in range(N):
	(r, w) = map(int, input().split())
	if b >= 10:
		print('NO')
		break
	elif r >= a and w >= b:
		a = r
		b = w
	else:
		print('NO')
		break
else:
	print('YES')


k = int(input())
(r, w, flag) = (0, 0, 0)
for i in range(k):
	(ri, wi) = [int(x) for x in input().split()]
	if i == 0:
		r = ri
		w = wi
	elif ri < r or wi < w:
		print('NO')
		flag = 1
		break
	elif w == wi and w == 10:
		print('NO')
		flag = 1
		break
	r = ri
	w = wi
if flag == 0:
	print('YES')


ans = 'YES'
lastr = 0
lastw = 0
for n in range(int(input())):
	(r, w) = map(int, input().split())
	if lastw < 10:
		if r >= lastr and w >= lastw:
			lastr = r
			lastw = w
		else:
			ans = 'NO'
			break
	else:
		ans = 'NO'
		break
print(ans)


t = int(input())
preWicket = 0
PreRuns = 0
count = 0
for i in range(t):
	(r, w) = list(map(int, input().split()))
	if r >= PreRuns and w >= preWicket and (w <= 10):
		count += 1
		if w == 10 and preWicket == 10:
			count -= 1
	PreRuns = r
	preWicket = w
if count == t:
	print('YES')
else:
	print('NO')


n = int(input())
arr = []
for n in range(n):
	arr.append([int(i) for i in input().split()])
flag = 1
if arr[0][1] > 10:
	flag = 0
for i in range(1, len(arr)):
	if arr[i][1] > 10:
		flag = 0
		break
	elif arr[i][0] < arr[i - 1][0] or arr[i][1] < arr[i - 1][1]:
		flag = 0
		break
	elif arr[i - 1][1] == arr[i][1] and arr[i - 1][1] == 10:
		flag = 0
		break
if flag == 0:
	print('NO')
else:
	print('YES')


rprev = 0
wprev = 0
valid = True
rec = int(input())
for irec in range(rec):
	(rnew, wnew) = map(int, input().split())
	if rnew < rprev or wnew < wprev or (wnew == 10 and irec < rec - 1) or (wnew > 10):
		valid = False
		print('NO')
		break
	else:
		rprev = rnew
		wprev = wnew
if valid == True:
	print('YES')


l = []
l1 = []
for i in range(int(input())):
	(r, w) = map(int, input().split())
	l.append(r)
	l1.append(w)
lst = l.copy()
lst.sort()
l2 = l1.copy()
l2.sort()
x = 0
for i in l1[:len(l1) - 1]:
	if i >= 10:
		x = 1
		break
if l == lst and max(l1) <= 10 and (l1 == l2) and (x == 0):
	print('YES')
else:
	print('NO')


n = int(input(''))
rPrev = 0
flag = 0
wPrev = 0
wickets = []
while n > 0:
	s = input('').split(' ')
	r = int(s[0])
	w = int(s[1])
	if r - rPrev >= 0 and w <= 10 and (w >= wPrev):
		flag = 0
		wickets.append(w)
	else:
		flag = 1
		break
	rPrev = r
	wPrev = w
	n -= 1
if flag == 0 and wickets.count(10) <= 1:
	print('YES')
else:
	print('NO')


T = int(input())
(a, b, k) = (0, 0, 0)
for _ in range(T):
	(Ri, Wi) = list(map(int, input().split()))
	if Ri < a or Wi < b:
		k = 1
		break
	if Ri > a and b == 10:
		k = 1
	a = Ri
	b = Wi
if k == 1:
	print('NO')
else:
	print('YES')


n = int(input())
run = wk = 0
f = 0
while n != 0:
	(r, w) = map(int, input().split())
	if r < run or w < wk:
		f = 1
		break
	if r > run and wk == 10:
		f = 1
		break
	run = r
	wk = w
	n -= 1
if f == 1:
	print('NO')
else:
	print('YES')


t = int(input())
h = []
while t:
	h.append([int(l) for l in input().split()])
	t = t - 1
sumi = 0
if h[0][1] > 10:
	hg = 9
else:
	hg = 99
for i in range(len(h) - 1):
	if (h[i + 1][0] < h[i][0] or h[i + 1][1] < h[i][1] or h[i + 1][1] > 10 or (h[i][1] >= 10)) and i >= 0:
		hg = 9
		break
if hg == 9:
	print('NO')
else:
	print('YES')


n = int(input())
r = 0
w = 0
for i in range(n):
	(ri, wi) = map(int, input().split())
	if ri < r or w >= 10:
		flag = False
		break
	else:
		r = max(r, ri)
		w = max(w, wi)
		flag = True
if flag:
	print('YES')
else:
	print('NO')


N = input()
N = int(N)
total = 0
list = []
for i in range(N):
	data = input().split()
	list.append(data)
run = []
wicket = []
for i in range(N):
	run.append(int(list[i][0]))
	wicket.append(int(list[i][1]))
run1 = sorted(run)
wicket1 = sorted(wicket)
if run1 == run and wicket1 == wicket and (max(wicket) < 11) and (N >= 1) and (N <= 10 ** 6) and (wicket.count(10) <= 1):
	print('YES')
else:
	print('NO')


n = int(input())
list1 = []
for i in range(0, n):
	input1 = input().split()
	list1.append(input1)
listrun = []
listwicket = []
for i in range(0, n):
	listrun.append(int(list1[i][0]))
	listwicket.append(int(list1[i][1]))
listrun2 = []
for i in listrun:
	listrun2.append(i)
listwicket2 = []
for j in listwicket:
	listwicket2.append(j)
listrun2.sort()
listwicket2.sort()
if max(listwicket) < 11 and listrun == listrun2 and (listwicket == listwicket2) and (n <= 10 ** 6) and (n >= 1) and (listwicket.count(10) <= 1):
	print('YES')
else:
	print('NO')


scores = int(input())
r = 0
w = 0
ans = 'YES'
for i in range(scores):
	(temp_r, temp_w) = map(int, input().split())
	if w == 10:
		ans = 'NO'
	if temp_r < r:
		ans = 'NO'
	if temp_w < w or temp_w > 10:
		ans = 'NO'
	(r, w) = (temp_r, temp_w)
print(ans)


t = int(input())
ri = []
wi = []
for i in range(t):
	(r, w) = map(int, input().split())
	ri.append(r)
	wi.append(w)
ans = False
for i in range(len(ri) - 1):
	if ri[i] > ri[i + 1]:
		ans = True
		break
for i in range(len(wi) - 1):
	if wi[i] > wi[i + 1]:
		ans = True
		break
	if wi[i] == 10 and i != len(wi) - 1:
		ans = True
		break
if ans:
	print('NO')
else:
	print('YES')


l = []
l1 = []
for i in range(int(input())):
	(r, w) = map(int, input().split())
	l.append(r)
	l1.append(w)
s = 1
for i in range(len(l) - 1):
	if l[i + 1] - l[i] < 0 or l1[i + 1] - l1[i] < 0:
		s = 0
		break
	if l1[i + 1] - l1[i] == 0 and l1[i] == 10:
		s = 0
		break
if s == 0:
	print('NO')
else:
	print('YES')


n = int(input())
r = []
w = []
for i in range(n):
	(r1, w1) = map(int, input().split())
	r.append(r1)
	w.append(w1)
flag = True
for i in range(0, n - 1):
	if r[i] > r[i + 1] or w[i] > w[i + 1]:
		flag = False
		break
	if w[i] == 10 and w[i] == w[i + 1]:
		flag = False
		break
if flag:
	print('YES')
else:
	print('NO')


score_list = []
wick_list = []
flag = 0
n = int(input(''))
for _ in range(n):
	(r, w) = map(int, input('').split())
	score_list.append(r)
	wick_list.append(w)
for i in range(n - 1):
	if score_list[i] > score_list[i + 1] or wick_list[i] > wick_list[i + 1]:
		flag = 1
		break
	elif wick_list[i] == wick_list[i + 1] == 10 and score_list[i] != score_list[i + 1]:
		flag = 1
		break
	else:
		flag = 0
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
fg = 0
l = []
for _ in range(n):
	(a, b) = map(int, input().split())
	l.append((a, b))
for i in range(1, n):
	if l[i][0] < l[i - 1][0]:
		fg = 1
		break
	elif l[i - 1][1] > l[i][1]:
		fg = 1
		break
	elif l[i - 1][1] == 10 and l[i][1] == 10 and (l[i - 1][0] != l[i][0]):
		fg = 1
		break
if fg == 0:
	print('YES')
else:
	print('NO')


n = int(input())
r = 0
w = 0
found = False
for _ in range(n):
	(ri, wi) = map(int, input().split())
	if wi < w:
		found = True
		break
	if ri < r:
		found = True
		break
	if w == 10:
		if ri > r:
			found = True
			break
	w = wi
	r = ri
if found:
	print('NO')
else:
	print('YES')


try:
	n = int(input())
	r = [0 for i in range(0, n)]
	w = [0 for i in range(0, n)]
	for i in range(0, n):
		(r[i], w[i]) = [int(j) for j in input().split()]
	valid = True
	for i in range(0, n - 1):
		if r[i] > r[i + 1] or w[i] > w[i + 1]:
			valid = False
			break
		if w[i] == 10 and w[i] == w[i + 1]:
			valid = False
			break
	if valid:
		print('YES')
	else:
		print('NO')
except:
	pass


n = int(input())
r = []
w = []
for i in range(n):
	(a, b) = map(int, input().split())
	r.append(a)
	w.append(b)
ans = 0
if n == 1 and w[i] <= 10:
	print('YES')
else:
	for i in range(n - 1):
		if r[i] <= r[i + 1] and w[i] <= w[i + 1]:
			if w[i] == 10 and w[i] == w[i + 1]:
				ans = 0
			else:
				ans = 1
		else:
			ans = 0
			break
	if ans == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
rl = []
wl = []
for i in range(n):
	(R, W) = list(map(int, input().split()))
	rl.append(R)
	wl.append(W)
found = 0
if n == 1 and wl[i] <= 10:
	print('YES')
else:
	for i in range(n - 1):
		if rl[i] <= rl[i + 1] and wl[i] <= wl[i + 1]:
			if wl[i] == 10 and wl[i] == wl[i + 1]:
				found = 0
			else:
				found = 1
		else:
			found = 0
			break
	if found == 0:
		print('NO')
	else:
		print('YES')


l = []
n = int(input())
for a0 in range(n):
	l.append(list(map(int, input().split())))
wicks = [l[i][1] for i in range(n)]
if sorted(l) == l and wicks.count(10) <= 1:
	print('YES')
else:
	print('NO')


import sys
ip = sys.stdin
n = int(ip.readline())
(pr, pw) = (0, 0)
i = 1
flag = True
while i <= n:
	(r, w) = map(int, ip.readline().split())
	if r < pr or w < pw:
		flag = False
		break
	if w == 10:
		break
	(pr, pw) = (r, w)
	i += 1
print('YES' if flag and i >= n else 'NO')


n = int(input())
(r, w) = list(map(int, input().split()))
f = 0
for i in range(n - 1):
	(a, b) = list(map(int, input().split()))
	if a < r or b < w or w == 10:
		f = 1
	r = a
	w = b
if f == 0:
	print('YES')
elif f == 1:
	print('NO')


n = int(input())
(x, y) = map(int, input().split())
i = 1
while i < n:
	(a, b) = map(int, input().split())
	if a >= x and b >= y:
		i += 1
		x = a
		y = b
		if b == 10:
			break
	else:
		break
if i == n:
	print('YES')
else:
	print('NO')


wl = [-1]
rp = [-1]
flag = 0
for _ in range(int(input())):
	(r, wt) = map(int, input().split())
	wl.append(wt)
	rp.append(r)
	if r < rp[-2] or wt > 10 or wt < wl[-2]:
		flag = 1
if flag == 1:
	print('NO')
elif wl.count(10) > 1:
	print('NO')
else:
	print('YES')


t = int(input())
n = t
runs = []
wckts = []
while t != 0:
	(r, w) = input().split()
	(r, w) = [int(r), int(w)]
	runs.append(r)
	wckts.append(w)
	t = t - 1
f = 0
for i in range(0, n):
	if i + 1 != n:
		if runs[i] > runs[i + 1]:
			f = 1
		if wckts[i] > wckts[i + 1]:
			f = 1
		if wckts[i] > 10:
			f = 1
		if wckts[i] == 10:
			if wckts[i - 1] == 10:
				f = 1
	else:
		if wckts[i] > 10:
			f = 1
		if wckts[i] == 10:
			if wckts[i - 1] == 10:
				f = 1
		break
if f == 0:
	print('YES')
else:
	print('NO')


n = int(input())
r = []
w = []
for i in range(n):
	(ri, wi) = map(int, input().split())
	r.append(ri)
	w.append(wi)
x = sorted(r)
f = 1
for i in range(n):
	if x[i] != r[i]:
		f = 0
		break
index = -1
for i in range(n):
	if w[i] == 10:
		index = i
		break
if index != -1:
	wea = r[index]
	for i in range(index + 1, n):
		if wea < r[i]:
			f = 0
			break
if f == 0:
	print('NO')
else:
	print('YES')


t = int(input())
m = 0
i = 0
k = 0
s = t
j = 0
while t > 0:
	(r, w) = map(int, input().split(' '))
	if r >= i and w >= k:
		m += 1
	if k == 10:
		j += 1
	i = r
	k = w
	t -= 1
if m == s and j == 0:
	print('YES')
else:
	print('NO')


N = int(input())
(R, W) = map(int, input().split())
flag = True
while N > 1:
	N = N - 1
	(R1, W1) = map(int, input().split())
	if R1 < R or W == 10 or W1 < W or (W1 > 10):
		flag = False
		break
	(R, W) = (R1, W1)
if flag == True:
	print('YES')
else:
	print('NO')


n = int(input())
run = []
wic = []
while n:
	(r, w) = [int(x) for x in input().split()]
	run.append(r)
	wic.append(w)
	n -= 1
srun = sorted(run)
swic = sorted(wic)
if srun == run and swic == wic and (max(wic) < 11) and (wic.count(10) < 2):
	print('YES')
else:
	print('NO')


n = int(input())
(runs, wic) = ([], [])
for _ in range(n):
	(r, w) = [int(x) for x in input().split()]
	runs.append(r)
	wic.append(w)
a = sorted(runs)
b = sorted(wic)
if runs == a and wic == b and all((i <= 10 for i in b)) and (b.count(10) <= 1):
	print('YES')
else:
	print('NO')


import sys
n = int(input())
for i in range(0, n):
	flag = 0
	(r, w) = sys.stdin.readline().split()
	r = int(r)
	w = int(w)
	if i == 0:
		prevr = r
		prevw = w
	else:
		if r < prevr:
			flag = 1
			break
		if (prevw >= 10 or w >= 10) and (not i == n - 1):
			flag = 1
			break
		prevr = r
		prevw = w
if flag == 0:
	print('YES')
else:
	print('NO')


r = []
w = []
t = []
for i in range(int(input())):
	(ri, wi) = input().split()
	r.append(int(ri))
	w.append(int(wi))
for i in range(1, len(r)):
	if w[i - 1] <= w[i] and r[i - 1] <= r[i]:
		t.append(1)
	else:
		t.append(0)
w.sort()
q = 0
for i in range(len(w)):
	if w[i] == 10:
		q += 1
if all((i == 1 for i in t)) and q <= 1:
	print('YES')
else:
	print('NO')


def greater10(ls):
	for i in ls:
		if i > 10:
			return True
	else:
		return False

def batAfterOut(wickets):
	count = 0
	for i in wickets:
		if i == 10:
			count += 1
	if count > 1:
		return True
	return False
T = int(input())
scores = []
for i in range(T):
	scores.append(list(map(int, input().split())))
runs = [a[0] for a in scores]
wickets = [a[1] for a in scores]
if runs != sorted(runs):
	print('NO')
elif wickets != sorted(wickets) or greater10(wickets) or batAfterOut(wickets):
	print('NO')
else:
	print('YES')


N = int(input())
score = list()
flag = 0
wicket = list()
if 1 <= N and N <= 10 ** 7:
	for i in range(N):
		temp = input().split()
		score.append(int(temp[0]))
		wicket.append(int(temp[1]))
	for i in range(1, N):
		if (score[i] < 1 or score[i] > 10 ** 7) or (wicket[i] < 0 or wicket[i] > 10) or score[i] < score[i - 1] or (wicket[i] < wicket[i - 1]) or (wicket[i - 1] == 10):
			flag = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')
elif N < 1 or N > 10 ** 7:
	print('NO')


n = int(input())
(a, b) = (0, 0)
check = True
for i in range(n):
	(r, w) = map(int, input().split())
	if i == 0:
		a = r
		b = w
	if check and a <= r and (w <= 9) and (b <= w):
		check = True
	elif w == 10 and b <= w and (i != n - 1):
		check = False
		break
	elif w == 10 and i == n - 1:
		check = True
	else:
		check = False
		break
	a = r
	b = w
if check:
	print('YES')
else:
	print('NO')


t = int(input(''))
flag = 1
for i in range(t):
	(r, w) = [int(x) for x in input().split()]
	if i == 0:
		prevR = r
		prevW = w
	else:
		if prevR > r or prevW > w:
			print('NO')
			flag = 0
			break
		if w == 10 and i != t - 1:
			print('NO')
			flag = 0
			break
	prevR = r
	prevW = w
if flag == 1:
	print('YES')


T = int(input())
pre_r = 0
pre_w = 0
flag = 1
for i in range(T):
	(r, w) = [int(x) for x in input().split(' ')]
	if i == 0:
		pre_r = r
		pre_w = w
	else:
		if w < pre_w:
			print('NO')
			flag = 0
			break
		if r < pre_r:
			print('NO')
			flag = 0
			break
		if w == 10:
			if i != T - 1:
				print('NO')
				flag = 0
				break
		pre_r = r
		pre_w = w
if flag == 1:
	print('YES')


import sys, math
n = int(input().strip())
(runs, wickets) = (0, 0)
glag = False
for a0 in range(n):
	(r, w) = map(int, input().strip().split(' '))
	if r < runs or (w >= 10 and a0 != n - 1):
		glag = True
	else:
		runs = r
		wickets = w
print('NO' if glag is True else 'YES')


flag = 0
n = int(input())
(a, b) = map(int, input().split())
for i in range(n - 1):
	(x, y) = map(int, input().split())
	if x < a or y < b or (b == 10 and x > a):
		flag = 1
		break
	else:
		(a, b) = (x, y)
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
f = False
a = [tuple(map(int, input().split())) for i in range(n)]
for i in range(n - 1):
	if (a[i + 1][0] < a[i][0] or a[i + 1][1] < a[i][1]) or f == True:
		print('NO')
		exit()
	if a[i][1] == 10:
		f = True
for i in range(n):
	if f == True:
		print('NO')
		exit()
	if a[i][1] == 10:
		f = True
print('YES')


t = int(input())
runs = []
wickets = []
i = 0
ans = 'YES'
while t > 0:
	(a, b) = [int(j) for j in input().split()]
	runs.append(a)
	wickets.append(b)
	if i > 0:
		if runs[i - 1] > runs[i]:
			ans = 'NO'
		elif wickets[i - 1] > wickets[i]:
			ans = 'NO'
			break
		elif wickets[i - 1] == wickets[i] and wickets[i] == 10:
			ans = 'NO'
	i += 1
	t -= 1
print(ans)


t = int(input())
arr = []
rs = []
ws = []
for i in range(t):
	(n, k) = map(int, input().split())
	rs.append(n)
	ws.append(k)
i = 0
flag = True
while flag == True:
	if rs[i] > rs[i + 1]:
		flag = False
	if ws[i] == 10 and ws[i + 1] == 10 or ws[i] > 10:
		flag = False
	if ws[i] > ws[i + 1]:
		flag = False
	i += 1
	if i == t - 1:
		break
if flag:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
(r, w) = ([], [])
for _ in range(n):
	(ri, wi) = map(int, input().split())
	r.append(ri)
	w.append(wi)
if w[0] > 10:
	print('NO')
	sys.exit()
score = 0
if w[0] == 10:
	score = r[0]
for i in range(1, n):
	if r[i] < r[i - 1]:
		print('NO')
		break
	if w[i] < w[i - 1]:
		print('NO')
		break
	if w[i] > 10:
		print('NO')
		break
	if w[i] == 10 and score == 0:
		score = r[i]
	if w[i] == 10 and r[i] > score:
		print('NO')
		break
else:
	print('YES')


t = int(input())
netr = 0
netw = 0
while t > 0:
	(r, w) = map(int, input().split())
	if r < netr or w < netw or w > 10:
		print('NO')
		exit()
	netr = r
	if w == 10:
		netw = 11
	else:
		netw = w
	t = t - 1
print('YES')


l = []
for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	l.append((x, y))
for i in range(len(l)):
	if l[i][1] > 10:
		print('NO')
		break
	elif i > 0 and l[i][0] < l[i - 1][0]:
		print('NO')
		break
	elif i != len(l) - 1 and l[i][1] == 10:
		print('NO')
		break
else:
	print('YES')


temp = 1
(r, w) = (0, 0)
for i in range(int(input())):
	(r1, w1) = map(int, input().split())
	if r <= r1 and w <= w1 and (w != 10):
		(r, w) = (r1, w1)
	else:
		temp = 0
if temp:
	print('YES')
else:
	print('NO')


n = int(input())
flag = 0
prevr = 0
prevw = 0
flag2 = 0
for _ in range(n):
	(r, w) = map(int, input().split())
	if prevr <= r and prevw <= w and (flag2 == 0):
		prevr = r
		prevw = w
	else:
		flag = 1
	if w == 10:
		flag2 = 1
if flag == 0:
	print('YES')
else:
	print('NO')


No_samples = int(input())
l = []
for _ in range(No_samples):
	sample = [int(x) for x in input().split()]
	l.append(sample)
R = W = 0
possible = 1
flag = 0
for (runs, wickets) in l:
	if runs < R or wickets < W:
		possible = 0
		break
	elif flag == 1 and wickets == 10:
		possible = 0
		break
	elif wickets == 10:
		flag = 1
	R = runs
	W = wickets
print('YES' if possible else 'NO')


case = int(input())
tmp_r = 0
tmp_w = 0
flag = 0
while case > 0:
	l = input().split(' ')
	if tmp_w == 10 and int(l[1]) == 10:
		flag = 1
		break
	if tmp_r <= int(l[0]):
		tmp_r = int(l[0])
	else:
		flag = 1
		break
	if tmp_w <= int(l[1]):
		tmp_w = int(l[1])
	else:
		flag = 1
		break
	case -= 1
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
flag = 0
(pr, pw) = map(int, input().split(' '))
for i in range(n - 1):
	(cr, cw) = map(int, input().split(' '))
	if pr > cr or pw > cw or pw == 10:
		print('NO')
		flag = 1
		break
	(pr, pw) = (cr, cw)
if flag == 0:
	print('YES')


import sys
import math
import string
t = int(input().strip())
(lr, lw) = ([], [])
while t > 0:
	l = list(map(int, input().strip().split(' ')))
	lr.append(l[0])
	lw.append(l[1])
	t = t - 1
l1 = sorted(lr)
l2 = sorted(lw)
if l1 == lr and l2 == lw and (lw[-1] <= 10) and (lw.count(10) <= 1):
	print('YES')
else:
	print('NO')


p = 0
pr = 0
pw = 0
z = 0
for _ in range(int(input())):
	(r, w) = input().split()
	r = int(r)
	w = int(w)
	if pw > w or pr > r:
		p = 1
	if w == 10 or z == 1:
		if z == 1:
			p = 1
		z = 1
	pw = w
	pr = r
if p == 0:
	print('YES')
else:
	print('NO')


t = int(input())
i = 0
a = 0
b = 0
while i < t:
	i = i + 1
	x = input().split(' ')
	x = list(map(int, x))
	if x[0] < a or x[1] < b or (b == 10 and x[1] == 10):
		print('NO')
		exit(0)
	a = x[0]
	b = x[1]
print('YES')


(r1, w1) = (0, 0)
res = 'YES'
i = 0
n = int(input())
for _ in range(n):
	i += 1
	(r, w) = [int(x) for x in input().split()]
	if w > 10 or (w == 10 and i < n):
		res = 'NO'
		break
	elif r >= r1 and w >= w1:
		(r1, w1) = (r, w)
		continue
	else:
		res = 'NO'
		break
print(res)


a = []
b = []
i = 0
for i in range(int(input())):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
if a == sorted(a) and b == sorted(b) and (sorted(b)[i] <= 10) and (b.count(10) <= 1):
	print('YES')
else:
	print('NO')


n = int(input().strip())
flag = True
(a, b) = (0, 0)
for p in range(n):
	arr = input().strip().split()
	(run, wic) = (int(arr[0]), int(arr[1]))
	if not (run < a or wic < b or wic > 10 or (b == 10)) and flag:
		a = run
		b = wic
	else:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


n = int(input(''))
s = 0
(r1, w1) = map(int, input().split())
for i in range(n - 1):
	(r, w) = map(int, input().split())
	if r < r1 or w < w1 or w1 == 10:
		print('NO')
		s = 1
		break
	if r1 <= r and w >= w1:
		r1 = r
		w1 = w
		continue
if s == 0:
	print('YES')


m = -1
flag = True
n = int(input())
for i in range(n):
	(r, w) = map(int, input().split())
	if r < m:
		flag = False
	else:
		m = r
	if w == 10 and i < n - 1:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
temp1 = 0
temp2 = 0
r = []
w = []
j = 0
count = 0
while j < n:
	lst = list(map(int, input().split()))
	r.append(lst[0])
	w.append(lst[1])
	j += 1
j = 0
while j < n:
	if temp2 < 10:
		if r[j] >= temp1:
			temp1 = r[j]
		else:
			break
		if w[j] >= temp2:
			temp2 = w[j]
		else:
			break
	else:
		break
	j += 1
if j == n:
	print('YES')
else:
	print('NO')


a = int(input())
x = []
y = []
flag = 0
for i in range(a):
	(a, b) = [int(k) for k in input().split()]
	x.append(a)
	y.append(b)
for i in range(len(x)):
	if y[i] > 10:
		flag = 0
		break
	if i == len(x) - 1:
		break
	elif x[i] <= x[i + 1] and (y[i] <= y[i + 1] and y[i] != 10):
		flag = 1
	else:
		flag = 0
		break
if flag:
	print('YES')
else:
	print('NO')


N = int(input())
ri = []
wi = []
for test in range(N):
	(run, wicket) = map(int, input().split())
	ri.append(run)
	wi.append(wicket)
flag = 0
for i in range(N - 1):
	if ri[i] > ri[i + 1] or wi[i] > wi[i + 1] or wi[i] == 10:
		flag = 1
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
valid = True
prevRun = 0
prevWicket = 0
wicketsDown = False
while n > 0:
	(run, wicket) = list(map(int, input().split()))
	if valid == True:
		if run < 0 or wicket < 0:
			valid = False
		if run < prevRun or wicket < prevWicket:
			valid = False
		if wicketsDown == True:
			valid = False
		prevRun = run
		prevWicket = wicket
		if wicket == 10:
			wicketsDown = True
	n = n - 1
if valid == True:
	print('YES')
else:
	print('NO')