Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef Aditi keeps changing the flavours of her dishes and she wants to analyse feedback from her customers in order to improve her performance. The customers visiting Aditi's restaurant can rate the food online and Aditi knows an aggregated rating for each day. As she is busy cooking, you should perform the data analysis.

You are given a sequence $A_{1}, A_{2}, \ldots, A_{N}$ of distinct integers denoting the customers' feedback during $N$ days. You should process $Q$ queries. In each query, you are given two integers $L$ and $R$. Consider any contiguous subsequence $A_{p}, A_{p+1}, \ldots, A_{q}$, where $L ≤ p < q ≤ R$; let's call it a *maximal increasing subsequence* if the following conditions hold:
$A_{p} < A_{p+1} \ldots < A_{q}$
if $p > L$, then $A_{p} < A_{p-1}$
if $q < R$, then $A_{q} > A_{q+1}$

Similarly, let's define a *maximal decreasing subsequence*. You should find out if the number of maximal increasing subsequences is equal to the number of maximal decreasing subsequences (with $L ≤ p < q ≤ R$).

For example, if $A = (10, 20, 30, 5)$, we can see that the only maximal increasing subsequence of this sequence (for $L=1$ and $R=N$) is $(10, 20, 30)$, since $(10, 20)$ does not satisfy the third condition and $(20, 30)$ does not satisfy the second condition, and there is only one maximal decreasing subsequence $(30, 5)$.

------  Input ------
The first line of the input contains two space-separated integers $N$ and $Q$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.
$Q$ lines follow. Each of these lines contains two space-separated integers $L$ and $R$ describing a query.

------  Output ------
For each query, print a single line containing the string "YES" if the number of maximal increasing contiguous subsequences is equal to the number of maximal decreasing contiguous subsequences or "NO" otherwise (without quotes).

------  Constraints ------
$2 ≤ N ≤ 10^{5}$
$1 ≤ Q ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{9}$ for each valid $i$
$1 ≤ L < R ≤ N$
$A_{1}, A_{2}, \ldots, A_{N}$ are pairwise distinct

------  Subtasks ------
Subtasks #1 (20 points): $Q ≤ 50$

Subtasks #2 (80 points): original constraints

----- Sample Input 1 ------ 
4 3
1 3 2 4
1 4
2 3
2 4
----- Sample Output 1 ------ 
NO
NO
YES
----- explanation 1 ------ 
For the first query, there are two maximal increasing subsequences $(1, 3)$ and $(2, 4)$, but only one maximal decreasing subsequence $(3, 2)$.

Difficulty: MEDIUM_HARD

Solutions:
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(q):
	(l, r) = map(int, input().split())
	if a[l - 1] < a[l] and a[r - 2] < a[r - 1] or (a[l - 1] > a[l] and a[r - 2] > a[r - 1]):
		print('NO')
	else:
		print('YES')


(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(Q):
	(L, R) = map(int, input().split())
	if A[L - 1] < A[L] and A[R - 2] < A[R - 1] or (A[L - 1] > A[L] and A[R - 2] > A[R - 1]):
		print('NO')
	else:
		print('YES')


import itertools
num = input().split()
length = int(num[0])
A = [int(i) for i in input().split()]
for i in range(int(num[1])):
	number = input().split()
	L = int(number[0])
	R = int(number[1])
	if R - L >= 2:
		if A[L] - A[L - 1] > 0 and A[R - 1] - A[R - 2] > 0 or (A[L] - A[L - 1] < 0 and A[R - 1] - A[R - 2] < 0):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


(m, n) = map(int, input().split())
seq = list(map(int, input().split()))
for i in range(n):
	(l, r) = map(int, input().split())
	if seq[l - 1] < seq[l] and seq[r - 2] > seq[r - 1] or (seq[l - 1] > seq[l] and seq[r - 2] < seq[r - 1]):
		print('YES')
	else:
		print('NO')


(N, Q) = map(int, input().split())
li = list(map(int, input().split()))
q = [list(map(int, input().split())) for _ in range(Q)]
H = [0 for _ in range(N)]
for i in range(N - 1):
	if li[i] < li[i + 1]:
		H[i] = 1
	elif li[i] > li[i + 1]:
		H[i] = -1
for (l, r) in q:
	if H[l - 1] == H[r - 2]:
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split(' '))
lst = [int(item) for item in input().split()]
for _ in range(q):
	(l, r) = map(int, input().split(' '))
	if lst[l - 1] < lst[l] and lst[r - 2] > lst[r - 1] or (lst[l - 1] > lst[l] and lst[r - 2] < lst[r - 1]):
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
ls = list(map(int, input().split()))
for i in range(q):
	(a, b) = map(int, input().split())
	if ls[a - 1] >= ls[a] and ls[b - 2] <= ls[b - 1] or (ls[a - 1] <= ls[a] and ls[b - 2] >= ls[b - 1]):
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split(' '))
l1 = [int(i) for i in input().split(' ')]
for i in range(q):
	(l, r) = map(int, input().split(' '))
	l -= 1
	r -= 1
	if l1[l + 1] > l1[l]:
		if l1[r - 1] > l1[r]:
			print('YES')
			continue
		else:
			print('NO')
			continue
	if l1[l + 1] < l1[l]:
		if l1[r - 1] < l1[r]:
			print('YES')
			continue
		else:
			print('NO')
			continue


(n, q) = map(int, input().split())
A = list(map(int, input().split()))
inc_f = 0
dec_f = 0
inc_count = [0] * n
dec_count = [0] * n
val = A[0]
change_set = set()
for i in range(1, n):
	if A[i] > val:
		if dec_f == 1:
			dec_count[i - 1] += dec_count[i - 2] + 1
			inc_count[i - 1] = inc_count[i - 2]
			dec_f = 0
			change_set.add(i - 1)
		else:
			dec_count[i - 1] = dec_count[i - 2]
			inc_count[i - 1] = inc_count[i - 2]
		inc_f = 1
	elif A[i] < val:
		if inc_f == 1:
			dec_count[i - 1] = dec_count[i - 2]
			inc_count[i - 1] += inc_count[i - 2] + 1
			inc_f = 0
			change_set.add(i - 1)
		else:
			dec_count[i - 1] = dec_count[i - 2]
			inc_count[i - 1] = inc_count[i - 2]
		dec_f = 1
	val = A[i]
if A[n - 1] > A[n - 2]:
	dec_count[n - 1] = dec_count[n - 2]
	inc_count[n - 1] += inc_count[n - 2] + 1
else:
	dec_count[n - 1] += dec_count[n - 2] + 1
	inc_count[n - 1] = inc_count[n - 2]
change_set.add(n - 1)
for test in range(q):
	i = 0
	d = 0
	(start, end) = map(int, input().split())
	if end - 1 in change_set:
		i = inc_count[end - 1] - inc_count[start - 1]
		d = dec_count[end - 1] - dec_count[start - 1]
	elif A[end - 1] > A[end - 2]:
		i = inc_count[end - 1] - inc_count[start - 1] + 1
		d = dec_count[end - 1] - dec_count[start - 1]
	else:
		i = inc_count[end - 1] - inc_count[start - 1]
		d = dec_count[end - 1] - dec_count[start - 1] + 1
	if i == d:
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
for _ in range(q):
	(l, r) = map(int, input().split())
	l -= 1
	r -= 1
	(a, b) = (0, 0)
	if arr[l] < arr[l + 1]:
		a = 1
	if arr[r] > arr[r - 1]:
		b = 1
	if a ^ b:
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
l = list(map(int, input().split()))
result = []
for i in range(len(l) - 1):
	if l[i] < l[i + 1]:
		result.append('UP')
	elif l[i] > l[i + 1]:
		result.append('DOWN')
for i in range(q):
	(l, r) = map(int, input().split())
	if result[l - 1] == result[r - 2]:
		print('NO')
	else:
		print('YES')


def seq(arr, l, r):
	if arr[l - 1 + 1] > arr[l - 1]:
		if arr[r - 1 - 1] < arr[r - 1]:
			return 'NO'
		else:
			return 'YES'
	elif arr[r - 1 - 1] > arr[r - 1]:
		return 'NO'
	else:
		return 'YES'
nq = list(map(int, input().strip().split()))
arr = list(map(int, input().strip().split()))
for i in range(0, nq[1]):
	lr = list(map(int, input().strip().split()))
	print(seq(arr, lr[0], lr[1]))


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (len(a) + 1)
for i in range(1, len(a) - 1):
	if a[i] > a[i - 1] and a[i] > a[i + 1] or (a[i] < a[i - 1] and a[i] < a[i + 1]):
		b[i + 1] = 1
for i in range(1, len(a) + 1):
	b[i] += b[i - 1]
while q > 0:
	(l, r) = map(int, input().split())
	if r == l + 1:
		print('NO')
	else:
		temp = b[r - 1] - b[l]
		if temp & 1 == 0:
			print('NO')
		else:
			print('YES')
	q -= 1


from sys import stdin
from bisect import bisect_right
MAX_LEN = 10 ** 5 + 5
MAX_CHAR = 26
cnt = [[0 for i in range(MAX_CHAR)] for j in range(MAX_LEN)]

def solve():
	(n, q) = map(int, stdin.readline().strip().split())
	a = list(map(int, stdin.readline().strip().split()))
	while q:
		q -= 1
		(l, r) = map(lambda x: int(x) - 1, stdin.readline().strip().split())
		if a[l] > a[l + 1] and a[r - 1] < a[r] or (a[l] < a[l + 1] and a[r - 1] > a[r]):
			print('YES')
		else:
			print('NO')
solve()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
	(l, r) = map(lambda x: int(x) - 1, input().split())
	if a[l] > a[l + 1] and a[r - 1] < a[r] or (a[l] < a[l + 1] and a[r - 1] > a[r]):
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
li = list(map(int, input().split()))
for i in range(0, q):
	(l, r) = map(int, input().split())
	l = l - 1
	r = r - 1
	if li[l] < li[l + 1] and li[r - 1] > li[r] or (li[l] > li[l + 1] and li[r - 1] < li[r]):
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
nl = list(map(int, input().split()))
m = [1] * n
for i in range(1, n):
	if nl[i] > nl[i - 1]:
		m[i] = 1
	else:
		m[i] = 0
m[0] = 0
for i in range(q):
	(l, r) = map(int, input().split())
	if m[l] != m[r - 1]:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
for i in range(m):
	(l, r) = map(lambda x: int(x) - 1, input().split())
	if (A[l] < A[l + 1]) == (A[r - 1] > A[r]):
		print('YES')
	else:
		print('NO')


def check(list_no, l, r):
	if list_no[l] < list_no[r]:
		return 1
	else:
		return 0
(n, q) = map(int, input().split())
numbers = list(map(int, input().split()))
for _ in range(0, q):
	(l, r) = map(int, input().split())
	l = l - 1
	r = r - 1
	count = 0
	count = check(numbers, l, l + 1)
	count += check(numbers, r - 1, r)
	if count == 1:
		print('YES')
	else:
		print('NO')


(N, Q) = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

def increasing(a, b):
	if a < b:
		return 1
	return 0
for k in range(Q):
	(L, R) = map(int, input().split(' '))
	counts = 0
	counts += increasing(A[L - 1], A[L])
	counts += increasing(A[R - 2], A[R - 1])
	if counts == 1:
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
l = list(map(int, input().split()))
p = [0] * (n + 1)
w = [0] * (n + 1)
k = [0] * (n + 1)
v = [0] * (n + 1)
i = 0
while i < n:
	i += 1
	d = 0
	x = i - 1
	while i < n and l[i] > l[i - 1]:
		d += 1
		i += 1
	if d:
		w[x + 1] += 1
		p[i] += 1
i = 0
while i < n:
	i += 1
	d = 0
	x = i - 1
	while i < n and l[i] < l[i - 1]:
		d += 1
		i += 1
	if d:
		v[x + 1] += 1
		k[i] += 1
for i in range(1, n + 1):
	p[i] += p[i - 1]
	w[i] += w[i - 1]
	v[i] += v[i - 1]
	k[i] += k[i - 1]
for i in range(q):
	(a, b) = map(int, input().split())
	x = p[b] - w[a - 1]
	y = k[b] - v[a - 1]
	if a - 1 != 0 and a - 1 != n - 1:
		if l[a - 2] < l[a - 1] < l[a]:
			x += 1
		if l[a - 2] > l[a - 1] > l[a]:
			y += 1
	if b - 1 != n - 1:
		if l[b - 2] > l[b - 1] > l[b]:
			y += 1
		if l[b - 2] < l[b - 1] < l[b]:
			x += 1
	if x == y:
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
num = list(map(int, input().split()))
for _ in range(q):
	(l, r) = map(int, input().split())
	if num[l - 1] < num[l] and num[r - 2] < num[r - 1] or (num[l - 1] > num[l] and num[r - 2] > num[r - 1]):
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(q):
	inc = 0
	dec = 0
	(l, r) = map(int, input().split())
	if arr[l - 1] < arr[l]:
		inc += 1
	if arr[r - 2] < arr[r - 1]:
		inc += 1
	if arr[l - 1] > arr[l]:
		dec += 1
	if arr[r - 2] > arr[r - 1]:
		dec += 1
	if inc == dec:
		print('YES')
	else:
		print('NO')


(n, q) = [int(d) for d in input().split()]
list1 = [int(f) for f in input().split()]
o = []
for i in range(n - 1):
	if list1[i + 1] - list1[i] > 0:
		o.append(1)
	elif list1[i + 1] - list1[i] < 0:
		o.append(-1)
for i in range(q):
	(l, r) = [int(g) for g in input().split()]
	if o[l - 1] != o[r - 2]:
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(q):
	(l, r) = map(int, input().split())
	if a[l - 1] < a[l] and a[r - 1] < a[r - 2]:
		print('YES')
	elif a[l - 1] > a[l] and a[r - 1] > a[r - 2]:
		print('YES')
	else:
		print('NO')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
for _ in range(m):
	(a, b) = map(int, input().split())
	if l[a] - l[a - 1] > 0 and l[b - 2] - l[b - 1] > 0:
		print('YES')
	elif l[a - 1] - l[a] > 0 and l[b - 1] - l[b - 2] > 0:
		print('YES')
	else:
		print('NO')


(n, q) = input().split()
n = int(n)
q = int(q)
li = input().split()
for _ in range(q):
	a = input().split()
	x1 = int(a[0])
	y1 = int(a[1])
	if int(li[x1 - 1]) > int(li[x1]) and int(li[y1 - 1]) > int(li[y1 - 2]) or (int(li[x1 - 1]) < int(li[x1]) and int(li[y1 - 1]) < int(li[y1 - 2])):
		print('YES')
	else:
		print('NO')


(n, q) = map(int, input('').split(' '))
li = list(map(int, input('').split(' ')))
for item in range(q):
	(l, r) = map(int, input('').split(' '))
	counti = 0
	countd = 0
	if li[l - 1] < li[l] and li[r - 1] > li[r - 2] or (li[l - 1] > li[l] and li[r - 1] < li[r - 2]):
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split())
x = list(map(int, input().split()))
l = []
for i in range(n - 1):
	if x[i] < x[i + 1]:
		l.append('1')
	else:
		l.append('0')
for i in range(q):
	(a, b) = map(int, input().split())
	if l[a - 1] != l[b - 2]:
		print('YES')
	else:
		print('NO')


L = list(map(int, input().split()))
l = list(map(int, input().split()))
for i in range(L[1]):
	m = list(map(int, input().split()))
	len = m[1] - m[0] + 1
	if l[m[0] - 1] > l[m[0]]:
		if l[m[1] - 1] > l[m[1] - 2]:
			print('YES')
		else:
			print('NO')
	if l[m[0] - 1] < l[m[0]]:
		if l[m[1] - 1] < l[m[1] - 2]:
			print('YES')
		else:
			print('NO')


(n, q) = map(int, input().split())
a = [int(x) for x in input().split()]
for _ in range(q):
	(L, R) = map(int, input().split())
	L = L - 1
	R = R - 1
	if a[L] < a[L + 1] and a[R - 1] > a[R] or (a[L] > a[L + 1] and a[R - 1] < a[R]):
		print('YES')
	else:
		print('NO')


(n, q) = input().split(' ')
n = int(n)
q = int(q)
a = [int(i) for i in input().split()]
while q > 0:
	q -= 1
	(x, y) = input().split(' ')
	x = int(x) - 1
	y = int(y) - 1
	if a[x] < a[x + 1] and a[y - 1] > a[y] or (a[x] > a[x + 1] and a[y - 1] < a[y]):
		print('YES')
	else:
		print('NO')


(_, t) = map(int, input().split())
arr = tuple(map(int, input().split()))
result = []
for i in range(len(arr) - 1):
	if arr[i] < arr[i + 1]:
		result.append('UP')
	elif arr[i] > arr[i + 1]:
		result.append('DOWN')
while t:
	t -= 1
	(l, r) = map(int, input().split())
	if result[l - 1] == result[r - 2]:
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
inc = [0] * (len(arr) + 1)
dec = [0] * (len(arr) + 1)
Range = set()
for i in range(1, n):
	if arr[i - 1] < arr[i] and (i + 1 == n or arr[i] > arr[i + 1]):
		inc[i] += 1
		Range.add(i)
for i in range(1, n):
	inc[i] = inc[i] + inc[i - 1]
for i in range(1, n):
	if arr[i - 1] > arr[i] and (i + 1 == n or arr[i] < arr[i + 1]):
		dec[i] += 1
		Range.add(i)
for i in range(1, n):
	dec[i] = dec[i] + dec[i - 1]
for _ in range(q):
	(l, r) = map(int, input().split())
	(l, r) = (l - 1, r - 1)
	if Range.issuperset({r}) is True:
		if inc[r] - inc[l] == dec[r] - dec[l]:
			print('YES')
		else:
			print('NO')
	else:
		if arr[r - 1] < arr[r]:
			if inc[r] - inc[l] + 1 == dec[r] - dec[l]:
				print('YES')
			else:
				print('NO')
		if arr[r - 1] > arr[r]:
			if inc[r] - inc[l] == dec[r] - dec[l] + 1:
				print('YES')
			else:
				print('NO')


(n, q) = map(int, input().split())
lst = [int(x) for x in input().split()]
ans = []
for _ in range(q):
	(l, r) = map(int, input().split())
	if lst[l] > lst[l - 1] and lst[r - 2] > lst[r - 1]:
		ans.append('YES')
	elif lst[l] < lst[l - 1] and lst[r - 2] < lst[r - 1]:
		ans.append('YES')
	else:
		ans.append('NO')
for item in ans:
	print(item)


(n, q) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
temp = [0] * n
for i in range(0, len(arr) - 1):
	if arr[i + 1] > arr[i]:
		temp[i] = 1
	else:
		temp[i] = 0
for i in range(q):
	(l, r) = map(int, input().split(' '))
	l -= 1
	r -= 1
	if temp[l] == temp[r - 1]:
		print('NO')
	else:
		print('YES')


(a, b) = list(map(int, input().strip().split()))
list1 = list(map(int, input().rstrip().split()))
for i in range(b):
	(L, R) = list(map(int, input().rstrip().split()))
	first1 = list1[L - 1]
	first2 = list1[L]
	last1 = list1[R - 2]
	last2 = list1[R - 1]
	if first1 > first2 and last1 < last2 or (first1 < first2 and last1 > last2):
		print('YES')
	else:
		print('NO')


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
l = []
for i in range(len(c) - 1):
	if c[i] < c[i + 1]:
		l.append('UP')
	elif c[i] > c[i + 1]:
		l.append('DOWN')
while b:
	b = b - 1
	(d, e) = map(int, input().split())
	if l[d - 1] == l[e - 2]:
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split())
o = list(map(int, input().split()))
for i in range(q):
	(l, r) = map(int, input().split())
	l = l - 1
	r = r - 1
	if o[l] < o[l + 1] and o[r - 1] > o[r]:
		print('YES')
	elif o[l] > o[l + 1] and o[r - 1] < o[r]:
		print('YES')
	else:
		print('NO')


(N, Q) = input().split()
arr = list(map(int, input().split()))
for i in range(int(Q)):
	(L, R) = input().split()
	L = int(L)
	R = int(R)
	if arr[L - 1] < arr[L] and arr[R - 2] < arr[R - 1] or (arr[L - 1] > arr[L] and arr[R - 2] > arr[R - 1]):
		print('NO')
	else:
		print('YES')


try:
	(N, Q) = map(int, input().split())
	list1 = list(map(int, input().split()))
	for i in range(Q):
		(l, r) = map(int, input().split())
		if list1[l - 1] < list1[l] and list1[r - 2] < list1[r - 1] or (list1[l - 1] > list1[l] and list1[r - 2] > list1[r - 1]):
			print('NO')
		else:
			print('YES')
except:
	pass


(N, Q) = [int(i) for i in input().split()]
A = list(map(int, input().split()))
for i in range(0, N):
	while Q:
		Q = Q - 1
		(L, R) = [int(i) for i in input().split()]
		if A[L - 1] > A[L] and A[R - 2] < A[R - 1] or (A[L - 1] < A[L] and A[R - 2] > A[R - 1]):
			print('YES')
		else:
			print('NO')


(n, q) = map(int, input().split())
a = [int(i) for i in input().split()]
while q > 0:
	(l, r) = [int(i) for i in input().split()]
	(l, r) = (l - 1, r - 1)
	if a[l] < a[l + 1] and a[r] < a[r - 1]:
		print('YES')
	elif a[l] > a[l + 1] and a[r] > a[r - 1]:
		print('YES')
	else:
		print('NO')
	q -= 1


(n, q) = (int(i) for i in input().split())
L = [int(i) for i in input().split()]
M = [0] * n
count = 1
M[0] = '*0'
for i in range(1, n - 1):
	if L[i] > L[i - 1] and L[i] > L[i + 1] or (L[i] < L[i - 1] and L[i] < L[i + 1]):
		M[i] = '*' + str(count)
		count += 1
	else:
		M[i] = '0' + str(count)
M[-1] = '0' + str(count)
for _ in range(q):
	(l, r) = (int(i) for i in input().split())
	l -= 1
	r -= 1
	if M[l][0] == '*':
		a = int(M[r][1:]) - int(M[l][1:]) - 1
	else:
		a = int(M[r][1:]) - int(M[l][1:])
	if a % 2 == 0:
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split())
li = list(map(int, input().split()))
result = []
for i in range(n - 1):
	if li[i] < li[i + 1]:
		result.append('1')
	elif li[i] > li[i + 1]:
		result.append('2')
for j in range(q):
	(l, r) = map(int, input().split())
	if result[l - 1] == result[r - 2]:
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split())
lst = list(map(int, input().split()))
for i in range(q):
	(l, r) = map(int, input().split())
	if lst[l] > lst[l - 1] and lst[r - 2] < lst[r - 1]:
		print('NO')
	elif lst[l] < lst[l - 1] and lst[r - 2] > lst[r - 1]:
		print('NO')
	elif lst[l] > lst[l - 1] and lst[r - 2] > lst[r - 1]:
		print('YES')
	elif lst[l] < lst[l - 1] and lst[r - 2] < lst[r - 1]:
		print('YES')


(n, q) = map(int, input().split())
lst = list(map(int, input().split()))
inc1 = [0] * n
inc2 = [0] * n
dec1 = [0] * n
dec2 = [0] * n
for i in range(1, n):
	if i + 1 < n and lst[i - 1] < lst[i] and (lst[i + 1] < lst[i]):
		inc1[i] = 1
		inc2[i] = 1
	elif i + 1 == n and lst[i - 1] < lst[i]:
		inc1[i] = 1
		inc2[i] = 1
	elif i + 1 < n and lst[i - 1] > lst[i] and (lst[i + 1] > lst[i]):
		dec1[i] = 1
		dec2[i] = 1
	elif i + 1 == n and lst[i - 1] > lst[i]:
		dec1[i] = 1
		dec2[i] = 1
inc = inc1
dec = dec1
for i in range(1, n):
	inc[i] = inc[i - 1] + inc[i]
	dec[i] = dec[i - 1] + dec[i]
for i in range(q):
	(l, r) = map(int, input().split())
	if inc2[r - 1] == 1 or dec2[r - 1] == 1:
		n_inc = inc[r - 1] - inc[l - 1]
		n_dec = dec[r - 1] - dec[l - 1]
	elif lst[r - 1] > lst[r - 2]:
		n_inc = inc[r - 1] - inc[l - 1] + 1
		n_dec = dec[r - 1] - dec[l - 1]
	elif lst[r - 1] < lst[r - 2]:
		n_dec = dec[r - 1] - dec[l - 1] + 1
		n_inc = inc[r - 1] - inc[l - 1]
	if n_inc == n_dec:
		print('YES')
	else:
		print('NO')


(N, Q) = map(int, input().strip().split())
A = list(map(int, input().strip().split()))
inc_seq = []
for i in range(N - 1):
	if A[i] < A[i + 1]:
		inc_seq.append(1)
	else:
		inc_seq.append(-1)
for _ in range(Q):
	(L, R) = map(int, input().strip().split())
	if inc_seq[R - 2] + inc_seq[L - 1] == 0 and R > L + 1:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
(N, Q) = map(int, stdin.readline().split())
array = list(map(int, stdin.readline().split()))
for _ in range(Q):
	(L, R) = map(int, stdin.readline().split())
	if array[L - 1] < array[L] and array[R - 1] < array[R - 2] or (array[L - 1] > array[L] and array[R - 1] > array[R - 2]):
		print('YES')
	else:
		print('NO')


ans = []
(n, q) = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(q):
	(l, r) = map(int, input().split())
	if a[l - 1] > a[l] and a[r - 1] < a[r - 2] or (a[l - 1] < a[l] and a[r - 1] > a[r - 2]):
		ans.append('NO')
	else:
		ans.append('YES')
[print(a) for a in ans]


(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
for q in range(Q):
	(L, R) = map(int, input().split())
	(Start, End) = ('', '')
	if A[L - 1] < A[L]:
		Start = 'I'
	else:
		Start = 'D'
	if A[R - 2] < A[R - 1]:
		End = 'I'
	else:
		End = 'D'
	if Start != End:
		print('YES')
	else:
		print('NO')


def isincreasing(a, b):
	if a < b:
		return 1
	return 0
(n, m) = map(int, input().split())
l1 = list(map(int, input().split()))
l1 = [0] + l1
for _ in range(m):
	count = 0
	(l, r) = map(int, input().split())
	count += isincreasing(l1[l], l1[l + 1])
	count += isincreasing(l1[r - 1], l1[r])
	if count == 1:
		print('YES')
	else:
		print('NO')


(n, q) = input().split(' ')
(n, q) = (int(n), int(q))
A = input().split(' ')
for i in range(n):
	A[i] = int(A[i])
for i in range(q):
	(l, r) = input().split(' ')
	(l, r) = (int(l), int(r))
	if (A[l - 1] < A[l] and A[r - 2] > A[r - 1] or (A[l - 1] > A[l] and A[r - 2] < A[r - 1])) and r - l != 1:
		print('YES')
	else:
		print('NO')


def FIND(L, A, B):
	COUNT = 0
	if L[A] < L[A + 1]:
		COUNT += 1
	if L[B - 1] < L[B]:
		COUNT += 1
	return 'YES' if COUNT == 1 else 'NO'
(N, Q) = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
for i in range(0, Q):
	(A, B) = [int(x) for x in input().strip().split(' ')]
	print(FIND(L, A - 1, B - 1))


(waste, lop) = list(map(int, input().split()))
arr = list(map(int, input().split()))
for _ in range(lop):
	(l, r) = list(map(int, input().split()))
	(l, r) = (l - 1, r - 1)
	if arr[l] < arr[l + 1] and arr[r - 1] < arr[r]:
		print('NO')
		continue
	elif arr[l] > arr[l + 1] and arr[r - 1] > arr[r]:
		print('NO')
		continue
	else:
		print('YES')


import sys, math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
for tt in range(t):
	(n, m) = invr()
	a = inlt()
	q = [0]
	w = [0]
	c = 0
	for i in range(1, len(a) - 1):
		if a[i - 1] > a[i] and a[i + 1] > a[i] or (a[i - 1] < a[i] and a[i + 1] < a[i]):
			q.append(1)
			c = c + 1
		else:
			q.append(0)
		w.append(c)
	q.append(1)
	w.append(w[-1] + 1)
	for i in range(m):
		(l, r) = invr()
		if q[r - 1] == 1:
			if (w[r - 1] - w[l - 1] - 1) % 2 != 0:
				print('YES')
			else:
				print('NO')
		elif (w[r - 1] - w[l - 1]) % 2 != 0:
			print('YES')
		else:
			print('NO')


(n, q) = input().split()
n = int(n)
q = int(q)
l = [int(s) for s in input().split()]
l1 = [0 for i in range(n)]
for i in range(n - 1):
	if l[i] < l[i + 1]:
		l1[i] = 1
while q > 0:
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	k1 = l1[l - 1]
	k2 = l1[r - 2]
	if k1 != k2:
		print('YES')
	else:
		print('NO')
	q -= 1


(n, q) = list(map(int, input().split()))
arr = list(map(int, input().split()))
b = []
b.append(1)
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		b.append(1)
	elif arr[i] < arr[i - 1]:
		b.append(-1)
while q != 0:
	(l, r) = map(int, input().split())
	if b[l] == b[r - 1]:
		print('NO')
	else:
		print('YES')
	q -= 1


(n, q) = [int(x) for x in input().split()]
alist = [int(x) for x in input().split()]
for i in range(q):
	(l, r) = [int(x) for x in input().split()]
	if alist[l - 1] > alist[l] and alist[r - 1] > alist[r - 2]:
		print('YES')
	elif alist[l - 1] < alist[l] and alist[r - 1] < alist[r - 2]:
		print('YES')
	else:
		print('NO')


def solve(A, l, r):
	if A[l] < A[l + 1] and A[r - 1] < A[r]:
		print('NO')
	elif A[l] > A[l + 1] and A[r - 1] > A[r]:
		print('NO')
	else:
		print('YES')
(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
for quer in range(q):
	(l, r) = map(int, input().split())
	(l, r) = (l - 1, r - 1)
	solve(arr, l, r)


(n, q) = map(int, input().split())
l = list(map(int, input().split()))
for i in range(q):
	(x, y) = map(int, input().split())
	x = x - 1
	y = y - 1
	if l[x] > l[x + 1] and l[y - 1] > l[y]:
		print('NO')
	elif l[x] < l[x + 1] and l[y - 1] < l[y]:
		print('NO')
	else:
		print('YES')


(n, q) = map(int, input().split())
arr = list(map(int, input().split()))
inc = [0] * n
dec = [0] * n
leng = 1
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		leng += 1
		inc[i] = inc[i - 1]
	else:
		if leng > 1:
			inc[i - 1] += 1
		inc[i] = inc[i - 1]
		leng = 1
if leng != 1:
	inc[n - 1] += 1
leng = 1
for i in range(1, n):
	if arr[i] < arr[i - 1]:
		leng += 1
		dec[i] = dec[i - 1]
	else:
		if leng > 1:
			dec[i - 1] += 1
		dec[i] = dec[i - 1]
		leng = 1
if leng != 1:
	dec[n - 1] += 1
while q:
	q -= 1
	(l, r) = map(int, input().split())
	l -= 1
	r -= 1
	r_ = inc[r]
	if r != n - 1 and arr[r] > arr[r - 1] and (arr[r] < arr[r + 1]):
		r_ += 1
	d_ = dec[r]
	if r != n - 1 and arr[r] < arr[r - 1] and (arr[r] > arr[r + 1]):
		d_ += 1
	if r_ - inc[l] == d_ - dec[l]:
		print('YES')
	else:
		print('NO')