Hr0d1y has $q$ queries on a binary string $s$ of length $n$. A binary string is a string containing only characters '0' and '1'.

A query is described by a pair of integers $l_i$, $r_i$ $(1 \leq l_i \lt r_i \leq n)$.

For each query, he has to determine whether there exists a good subsequence in $s$ that is equal to the substring $s[l_i\ldots r_i]$.

A substring $s[i\ldots j]$ of a string $s$ is the string formed by characters $s_i s_{i+1} \ldots s_j$.

String $a$ is said to be a subsequence of string $b$ if $a$ can be obtained from $b$ by deleting some characters without changing the order of the remaining characters.

A subsequence is said to be good if it is not contiguous and has length $\ge 2$. For example, if $s$ is "1100110", then the subsequences $s_1s_2s_4$ ("1100110") and $s_1s_5s_7$ ("1100110") are good, while $s_1s_2s_3$ ("1100110") is not good.

Can you help Hr0d1y answer each query?


-----Input-----

The first line of the input contains a single integer $t$ ($1\leq t \leq 100$) — the number of test cases. The description of each test case is as follows.

The first line contains two integers $n$ ($2 \leq n \leq 100$) and $q$ ($1\leq q \leq 100$) — the length of the string and the number of queries.

The second line contains the string $s$.

The $i$-th of the next $q$ lines contains two integers $l_i$ and $r_i$ ($1 \leq l_i \lt r_i \leq n$).


-----Output-----

For each test case, output $q$ lines. The $i$-th line of the output of each test case should contain "YES" if there exists a good subsequence equal to the substring $s[l_i...r_i]$, and "NO" otherwise.

You may print each letter in any case (upper or lower).


-----Examples-----

Input
2
6 3
001000
2 4
1 3
3 5
4 2
1111
1 4
2 3
Output
YES
NO
YES
NO
YES


-----Note-----

In the first test case,

$s[2\ldots 4] = $ "010". In this case $s_1s_3s_5$ ("001000") and $s_2s_3s_6$ ("001000") are good suitable subsequences, while $s_2s_3s_4$ ("001000") is not good.

$s[1\ldots 3] = $ "001". No suitable good subsequence exists.

$s[3\ldots 5] = $ "100". Here $s_3s_5s_6$ ("001000") is a suitable good subsequence.

Difficulty: EASY

Solutions:
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	for j in range(k):
		(l, r) = map(int, input().split())
		s2 = s[l - 1:r]
		if s2[0] in s[:l - 1] or s2[-1] in s[r:]:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, q) = map(int, input().split())
	a = input()
	for k in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		d = 0
		y = r + 1
		e = True
		while d < l and e == True:
			if a[d] == a[l]:
				e = False
			d += 1
		while y < len(a) and e == True:
			if a[y] == a[r]:
				e = False
			y += 1
		print('NO' if e == True else 'YES')


import sys, math
input = sys.stdin.readline
t = int(input())
for tttt in range(t):
	(n, q) = map(int, input().split())
	s = input().strip('\n')
	for qq in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		flag = False
		for i in range(0, l):
			if s[i] == s[l]:
				flag = True
				break
		for i in range(r + 1, n):
			if s[i] == s[r]:
				flag = True
				break
		if flag == True:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(x, y) = map(int, input().split())
		if abs(y - x) == n:
			print('NO')
		if x == y:
			print('NO')
		else:
			an = -1
			l = s[x - 1]
			r = s[y - 1]
			if x != 1:
				for i in range(x - 1):
					if s[i] == l:
						an = 1
						break
			if y != n:
				for i in range(y, n):
					if s[i] == r:
						an = 1
						break
			if an == -1:
				print('NO')
			else:
				print('YES')


import sys
input = sys.stdin.readline

def good(string, left, right):
	if left > 1 and string[left - 1] in string[0:left - 1]:
		return True
	elif right < len(string) and string[right - 1] in string[right:]:
		return True
	else:
		return False
tests = int(input())
for test in range(tests):
	(stringLength, testcases) = map(int, input().split())
	string = input()
	for testcase in range(testcases):
		(left, right) = map(int, input().split())
		if good(string, left, right):
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, q) = input().split()
	(n, q) = (int(n), int(q))
	s = input()
	for j in range(q):
		(l, r) = input().split()
		(l, r) = (int(l), int(r))
		if l == 1 and r == n:
			print('NO')
		elif s[l - 1] in s[:l - 1]:
			print('YES')
		elif s[r - 1] in s[r:]:
			print('YES')
		else:
			print('NO')


for t in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	ler = [(int(j) for j in input().split()) for i in range(q)]
	for (l, r) in ler:
		(l, r) = (l - 1, r - 1)
		flag = False
		d = s[l:r + 1]
		(fc, lc) = (d[0], d[-1])
		p = 0
		for i in range(l):
			if s[i] == fc:
				flag = True
		for i in range(r + 1, n):
			if s[i] == lc:
				flag = True
		print('YES' if flag else 'NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(l, r) = map(int, input().split())
		temp = s[l - 1:r]
		if temp[0] in s[0:l - 1] or temp[-1] in s[r:]:
			print('YES')
		else:
			print('NO')


for _ in range(0, int(input())):
	(n, q) = map(int, input().split())
	v = input()
	f0 = v.find('0')
	f1 = v.find('1')
	l0 = n - v[::-1].find('0') - 1
	l1 = n - v[::-1].find('1') - 1
	for _ in range(0, q):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		print(['YES', 'NO'][(f0 == a or f1 == a) and (l0 == b or l1 == b)])


import sys
input = sys.stdin.readline

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	for _ in range(int(input())):
		(n, q) = map(int, input().split())
		s = input()
		for z in range(q):
			(l, r) = map(int, input().split())
			l -= 1
			r -= 1
			j = l
			prev = -1
			sels = []
			fi = -1
			la = -1
			f = 0
			for i in range(n):
				if s[i] == s[j]:
					j += 1
					sels.append(i)
					if j == r + 1:
						la = i
						break
				if prev == -1:
					fi = i
					prev = i
				else:
					if i - prev != 1:
						f = 1
					prev = i
			if j == r + 1:
				if f:
					print('YES')
				else:
					for i in range(1, len(sels)):
						if s[sels[i]] != s[sels[i - 1]] and sels[i] - sels[i - 1] != 1:
							f = 1
							break
					if f:
						print('YES')
					else:
						for i in range(sels[len(sels) - 1] + 1, n):
							if s[i] == s[sels[len(sels) - 1]]:
								f = 1
						if f:
							print('YES')
						else:
							print('NO')
			else:
				print('NO')
	return
main()


t = int(input())
for z in range(t):
	(n, q) = map(int, input().split())
	s = input()
	ok = 0
	for y in range(q):
		(l, r) = map(int, input().split())
		if s[l - 1] in s[:l - 1] or s[r - 1] in s[r:]:
			print('YES')
		else:
			print('NO')


import sys

def get_single_int():
	return int(sys.stdin.readline().strip())

def get_string():
	return sys.stdin.readline().strip()

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
for i in range(get_single_int()):
	(n, q) = get_ints()
	s = get_string()
	for j in range(q):
		(l, r) = get_ints()
		l = l - 1
		ss = s[l:r]
		if l == 0:
			if ss[r - l - 1] in s[r:]:
				print('YES')
			else:
				print('NO')
		elif r - 1 == n - 1:
			if ss[0] in s[:l]:
				print('YES')
			else:
				print('NO')
		elif ss[0] in s[:l] or ss[r - l - 1] in s[r:]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for x in range(q):
		(l, r) = map(int, input().split())
		p = s[l - 1:r]
		if p[-1] in s[r:] or p[0] in s[:l - 1]:
			print('YES')
		else:
			print('NO')


for t in range(int(input())):
	(n, q) = [int(_) for _ in input().split()]
	s = input()
	for a in range(q):
		(l1, r1) = [int(_) for _ in input().split()]
		(l, r) = (min(l1, r1) - 1, max(l1, r1) - 1)
		(ts1, ts2) = (s[:l], s[r + 1:])
		if ts1.count(s[l]) > 0 or ts2.count(s[r]) > 0:
			print('YES')
		else:
			print('NO')


n = int(input())
for j in range(0, n):
	(n, q) = map(int, input().split())
	a = input()
	for i in range(0, q):
		(l, r) = map(int, input().split())
		l = l - 1
		r = r - 1
		if r - l >= n - 1:
			print('NO')
		else:
			s = False
			for k in range(0, l):
				if a[k] == a[l]:
					s = True
					break
			if not s:
				for v in range(r + 1, n):
					if a[v] == a[r]:
						s = True
						break
			if s:
				print('YES')
			else:
				print('NO')


from collections import *
from heapq import *
from itertools import *
from functools import *
from random import *
import sys
INF = float('Inf')

def genTokens(lines):
	for line in lines:
		for token in line.split():
			yield token

def nextFn(fn):
	return lambda it: fn(it.__next__())
nint = nextFn(int)
nstr = nextFn(str)

def genCases():
	it = genTokens(sys.stdin)
	T = nint(it)
	for _ in range(T):
		N = nint(it)
		Q = nint(it)
		S = nstr(it)
		Qs = []
		for _ in range(Q):
			Qs.append((nint(it), nint(it)))
		yield (N, Q, S, Qs)

def main():
	for case in genCases():
		solve(case)

def solve(case):
	(N, Q, S, Qs) = case
	for (li, ri) in Qs:
		if li == ri:
			print('NO')
		elif S[li - 1] in S[:li - 1] or S[ri - 1] in S[ri:]:
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(l, r) = map(int, input().split())
		check = False
		for j in range(l - 1):
			if s[j] == s[l - 1]:
				check = True
				break
		for j in range(r, n):
			if s[j] == s[r - 1]:
				check = True
				break
		if check:
			print('YES')
		else:
			print('NO')


import random

def main():
	t = int(input())
	for _ in range(t):
		(n, q) = list(map(int, input().split()))
		s = input()
		zo = []
		z = 0
		o = 0
		for i in reversed(range(n)):
			if s[i] == '0':
				z += 1
				zo.append((z, o))
			else:
				o += 1
				zo.append((z, o))
		zo = list(reversed(zo))
		for _ in range(q):
			(l, r) = list(map(int, input().split()))
			flag = 0
			if s[l - 1] == '0':
				if zo[0][0] - zo[l - 1][0] > 0:
					print('YES')
					flag = 1
			elif zo[0][1] - zo[l - 1][1] > 0:
				print('YES')
				flag = 1
			if flag == 0:
				if s[r - 1] == '0':
					if zo[r - 1][0] - 1 > 0:
						print('YES')
						flag = 1
				elif zo[r - 1][1] - 1 > 0:
					print('YES')
					flag = 1
			if flag == 0:
				print('NO')
main()


def fun(s, s1):
	n = len(s)
	m = len(s1)
	t = [[0 for i in range(m + 1)] for j in range(n + 1)]
	for i in range(m + 1):
		t[i][0] = 1
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			if s[i - 1] == s1[j - 1]:
				t[i][j] = t[i - 1][j - 1] + t[i - 1][j]
			else:
				t[i][j] = t[i - 1][j]
	return t[n][m]
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(l, r) = map(int, input().split())
		st = False
		if s[l - 1] in s[:l - 1]:
			st = True
		if s[r - 1] in s[r:]:
			st = True
		if st:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input().strip()
	for z in range(q):
		(l, r) = map(int, input().split())
		if l - r >= n - 1:
			print('NO')
		elif l >= 1:
			x = s[l - 1]
			if x in s[:l - 1]:
				print('YES')
			else:
				y = s[r - 1]
				if y in s[r:]:
					print('YES')
				else:
					print('NO')
		else:
			y = s[r - 1]
			if y in s[r:]:
				print('YES')
			else:
				print('NO')


import sys
input = sys.stdin.readline
for test in range(int(input())):
	(n, q) = [int(i) for i in input().split()]
	s = input()
	for _ in range(q):
		(l, r) = [int(i) for i in input().split()]
		sub = s[l - 1:r]
		x = sub[0] in s[:l - 1]
		y = sub[-1] in s[r:]
		ans = ''
		if x and y:
			ans = 'YES'
		elif x and (not y):
			if sub[0] in s[:l - 1]:
				ans = 'YES'
			else:
				ans = 'NO'
		elif not x and y:
			if sub[-1] in s[r:]:
				ans = 'YES'
			else:
				ans = 'NO'
		else:
			ans = 'NO'
		print(ans)


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


t = int(input())
for i in range(t):
	(n, q) = list(map(int, input().split()))
	s = input()
	for j in range(q):
		(l, r) = list(map(int, input().split()))
		if l - r + 1 == n:
			print('NO')
		else:
			x = s[l - 1:r]
			i1 = s.find(x[0])
			i2 = s.rfind(x[-1])
			if i1 != l - 1 or i2 != r - 1:
				print('YES')
			else:
				print('NO')


def sub(a, b):
	n = len(a)
	l = len(b)
	if l < n:
		return False
	if l == n:
		return a == b
	d = 0
	for i in range(l):
		if a[d] == b[i]:
			d += 1
		if d >= n:
			break
	return d >= n
for _ in range(int(input())):
	(n, q) = [int(x) for x in input().split(' ')]
	a = input()
	for i in range(q):
		(l, r) = [int(x) for x in input().split(' ')]
		l = l - 1
		r = r - 1
		found = False
		sf = a[l:r + 1]
		n = len(a)
		for j in range(l, r + 1):
			found = sub(sf, a[0:j] + a[j + 1:n])
			if found:
				break
		if found:
			print('YES')
		else:
			print('NO')


def solve(n, s, l, r, one, zro):
	if r - l + 1 < 2:
		return 'NO'
	x = s[l]
	y = s[r]
	if x == '0':
		if zro[0] < l:
			return 'YES'
	if x == '1':
		if one[0] < l:
			return 'YES'
	if y == '0':
		if zro[-1] > r:
			return 'YES'
	if y == '1':
		if one[-1] > r:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(n, q) = map(int, input().split(' '))
	s = input()
	one = []
	zro = []
	for i in range(n):
		if s[i] == '0':
			zro.append(i)
		else:
			one.append(i)
	for i in range(q):
		(l, r) = map(int, input().split(' '))
		print(solve(n, s, l - 1, r - 1, one, zro))


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	a = [0] * (n + 1)
	for i in range(n):
		a[i + 1] = a[i] + (s[i] == '1')
	for _ in range(q):
		(l, r) = map(int, input().split())
		yes = False
		if l > 1:
			if s[l - 1] == '0':
				if a[l - 1] < l - 1:
					yes = True
			elif a[l - 1] > 0:
				yes = True
		if not yes:
			if r < n:
				if s[r - 1] == '0':
					if a[n] - a[r] < n - r:
						yes = True
				elif a[n] - a[r] > 0:
					yes = True
		print('YES' if yes else 'NO')


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	(n, q) = neo()
	s = input()
	for i in range(q):
		(l, r) = Neo()
		t = s[l - 1:r]
		if t[0] in s[:l - 1] or t[-1] in s[r:]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for x in range(q):
		ans = 'NO'
		(l, r) = map(int, input().split())
		(start, end) = (s[l - 1], s[r - 1])
		if start in s[:l - 1]:
			ans = 'YES'
		elif end in s[r:]:
			ans = 'YES'
		print(ans)


from sys import stdin
from collections import deque
input = stdin.readline
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = ' ' + input().rstrip() + '  '
	for x in range(q):
		(l, r) = map(int, input().split())
		if s[l] in s[:l] or s[r] in s[r + 1:]:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, q) = list(map(int, input().split(' ')))
	s = input()
	for __ in range(q):
		(l, r) = list(map(int, input().split(' ')))
		res = s[l - 1:r - 1]
		t1 = s[0:l - 1]
		t2 = ''
		if n > r:
			t2 = s[r:]
		if s[l - 1] in t1 or s[r - 1] in t2:
			print('YES')
		else:
			print('NO')


def solve(n, q, s, queries):
	mn = [-1, -1]
	mx = [-1, -1]
	for i in range(n):
		mx[int(s[i])] = i
		if mn[int(s[i])] == -1:
			mn[int(s[i])] = i
	for (l, r) in queries:
		if mn[int(s[l])] < l or mx[int(s[r])] > r:
			print('YES')
		else:
			print('NO')
t = int(input())
while t:
	(n, q) = map(int, input().split())
	s = input()
	queries = []
	for _ in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		queries.append([l, r])
	solve(n, q, s, queries)
	t -= 1


import sys, functools, collections, bisect, math, heapq
input = sys.stdin.readline
mod = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().strip().split())
	s = input().strip()
	leftzero = s.find('0')
	leftone = s.find('1')
	rightone = -1
	rightzero = -1
	one = 1
	zero = 1
	for i in range(n - 1, -1, -1):
		if one and s[i] == '1':
			rightone = i
			one = 0
		if zero and s[i] == '0':
			rightzero = i
			zero = 0
		if zero == 0 and one == 0:
			break
	for i in range(q):
		(l, r) = map(int, input().strip().split())
		l -= 1
		r -= 1
		if l > 0 and s[l] == '1' and (l > leftone >= 0):
			print('YES')
			continue
		elif l > 0 and s[l] == '0' and (l > leftzero >= 0):
			print('YES')
			continue
		if r < n - 1 and s[r] == '1' and (r < rightone):
			print('YES')
			continue
		if r < n - 1 and s[r] == '0' and (r < rightzero):
			print('YES')
			continue
		print('NO')


t = int(input())
a = []
for _ in range(t):
	(n, q) = [int(x) for x in input().split()]
	s = input()
	for _ in range(q):
		(l, r) = [int(x) for x in input().split()]
		if l > 1 and s[l - 1] in s[:l - 1] or (r < n and s[r - 1] in s[r:]):
			a.append('YES')
		else:
			a.append('NO')
print('\n'.join(a))


for _ in range(int(input())):
	(n, a) = map(int, input().split())
	s = input()
	for __ in range(a):
		(l, r) = map(int, input().split())
		s1 = s[l - 1:r]
		ans1 = False
		ans2 = False
		(a, b) = (s1[0], s1[-1])
		for i in s[:l - 1]:
			if i == a:
				ans1 = True
				break
		for i in s[r:]:
			if i == b:
				ans2 = True
				break
		if ans1 or ans2:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input()
	for _ in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		lf = s.find(s[l])
		rf = s.rfind(s[r])
		print('YES' if lf < l or rf > r else 'NO')


def solve():
	(n, q) = map(int, input().split())
	s = input()
	while q:
		(l, r) = map(int, input().split())
		r -= 1
		l -= 1
		flag = 0
		for i in range(r + 1, n):
			if s[i] == s[r]:
				print('YES')
				flag = 1
				break
		if flag == 0:
			for i in range(l - 1, -1, -1):
				if s[i] == s[l]:
					print('YES')
					flag = 1
					break
		if flag == 0:
			print('NO')
		q -= 1
for _ in range(int(input())):
	solve()


from sys import stdin
input = stdin.readline
t = int(input())
for i in range(t):
	(n, q) = map(int, input().split())
	s = input()
	s = [None] + list(s)
	for i in range(q):
		(l, r) = map(int, input().split())
		if s[l] in s[1:l] or s[r] in s[r + 1:]:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(input())
	now = [[0, 0] for i in range(n)]
	for i in range(k):
		(l, r) = map(int, input().split())
		fl = 0
		for i in range(l - 1):
			if a[i] == a[l - 1]:
				fl = 1
		for i in range(r, n):
			if a[i] == a[r - 1]:
				fl = 1
		if fl == 1:
			print('YES')
		else:
			print('NO')


def getIn(arr):
	x = arr.split()
	for i in range(len(x)):
		x[i] = int(x[i])
	return x
t = int(input())
for i in range(t):
	nq = getIn(input())
	q = nq[1]
	string = input()
	for j in range(q):
		lr = getIn(input())
		fi = lr[0] - 1
		li = lr[1] - 1
		f = string[fi]
		l = string[li]
		fh = string[:fi]
		lh = string[li + 1:]
		if fh.find(f) == -1 and lh.find(l) == -1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	if len(set(s)) == 1:
		for __ in range(q):
			(l, r) = map(int, input().split())
			if r - l < 1 or r - l + 1 == n:
				print('NO')
			else:
				print('YES')
	else:
		a = [[s.index('0'), s.rindex('0')], [s.index('1'), s.rindex('1')]]
		for __ in range(q):
			(l, r) = map(int, input().split())
			l -= 1
			r -= 1
			if r - l >= 1 and (a[int(s[l])][0] < l or a[int(s[r])][1] > r):
				print('YES')
			else:
				print('NO')


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(l, r) = map(int, input().split())
		if r == l:
			print('NO')
			continue
		before = s.find(s[l - 1])
		if before != -1 and before < l - 1:
			print('YES')
			continue
		elif r == n or s.find(s[r - 1], r) == -1:
			print('NO')
		else:
			print('YES')


def helper(s, l, r):
	i = 0
	for c in range(l, r + 1):
		while s[c] != s[i]:
			i += 1
		if c == l:
			first = i
		if c == r:
			last = i
		i += 1
	if last - first != r - l:
		return True
	else:
		for j in range(i, len(s)):
			if s[j] == s[r]:
				return True
	return False
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for query in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		if helper(s, l, r):
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	r = [int(x) for x in input().split()]
	s = input()
	firstZero = r[0] + 1
	firstOne = r[0] + 1
	lastZero = -1
	lastOne = -1
	for j in range(r[0]):
		if s[j] == '0':
			if firstZero == r[0] + 1:
				firstZero = j
			lastZero = j
		else:
			if firstOne == r[0] + 1:
				firstOne = j
			lastOne = j
	for j in range(r[1]):
		l = [int(x) - 1 for x in input().split()]
		pos = False
		if lastZero != l[1] and lastOne != l[1]:
			pos = True
		if firstZero != l[0] and firstOne != l[0]:
			pos = True
		if pos == True:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for __ in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		bad = True
		i = 0
		while i < l and bad:
			if s[i] == s[l]:
				bad = False
			i += 1
		i = r + 1
		while i < n and bad:
			if s[i] == s[r]:
				bad = False
			i += 1
		print('NO' if bad else 'YES')


for t in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	sl = list(s)
	for _ in range(q):
		(l, r) = map(int, input().split())
		st = sl[l - 1:r]
		flag = False
		index = []
		for i in range(l - 1):
			if s[i] == st[0]:
				flag = True
		for i in range(r, len(s)):
			if s[i] == st[-1]:
				flag = True
		if flag:
			print('YES')
		else:
			print('NO')


for x in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for x in range(q):
		(l, r) = map(int, input().split())
		s1 = s[l - 1:r]
		p = s1[0]
		q = s1[r - l]
		(t, t1) = (0, 0)
		for y in range(0, l - 1):
			if s[y] == p:
				t = 1
				break
		for y in range(r, n):
			if s[y] == q:
				t1 = 1
				break
		if t == 1 or t1 == 1:
			print('YES')
		else:
			print('NO')


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for j in range(q):
		(l, r) = map(int, input().split())
		x = s.find(s[l - 1])
		y = s.rfind(s[r - 1])
		if l - 1 != x or r - 1 != y:
			print('YES')
		else:
			print('NO')


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def nCr(n, r):
	i = 1
	while i < r:
		n *= n - i
		i += 1
	return n // math.factorial(r)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	(n, q) = spin()
	s = 'B'
	s += stin()
	for i in range(q):
		(l, r) = spin()
		sub = s[l:r + 1]
		left = s[1:l + 1]
		right = s[r:]
		if left.count(sub[0]) > 1 or right.count(sub[-1]) > 1:
			print('YES')
		else:
			print('NO')


import sys
readline = sys.stdin.readline
t = int(readline())
for _ in range(t):
	(n, q) = map(int, readline().split())
	s = list(readline().strip('\n'))
	for i in range(q):
		(l, r) = map(int, readline().split())
		l -= 1
		r -= 1
		if l > 0:
			if s[l] in set(s[:l]):
				print('YES')
				continue
		if r < n - 1:
			if s[r] in set(s[r + 1:]):
				print('YES')
				continue
		print('NO')


l = lambda : map(int, input().split())
p = lambda : int(input())
ss = lambda : input()
for _ in range(p()):
	(n, q) = l()
	s = input()
	for i in range(q):
		(R, L) = l()
		if s[R - 1] in s[:R - 1]:
			print('YES')
		elif s[L - 1] in s[L:]:
			print('YES')
		else:
			print('NO')


t = int(input())

def solve():
	(n, q) = map(int, input().split())
	s = input()
	Q = []
	for i in range(q):
		Q.append(tuple(map(int, input().split())))
	for i in Q:
		l = i[0] - 1
		r = i[1]
		if s[l] in s[:l] or s[r - 1] in s[r:]:
			print('YES')
		else:
			print('NO')
for i in range(t):
	solve()


import sys, os.path
from collections import *
from heapq import *
from copy import *
import math
mod = 998244353
read = lambda : map(int, input().split())
inf = float('inf')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	(n, q) = read()
	s = input()
	for q1 in range(q):
		(l, r) = read()
		flag = 0
		for j in range(l - 1):
			if s[l - 1] == s[j]:
				flag = 1
				break
		for j in range(r, n):
			if s[r - 1] == s[j]:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


from sys import stdin
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	for ii in range(k):
		(a, b) = [int(i) for i in input().split()]
		aa = min([a, b])
		b = max([a, b])
		a = aa - 1
		ss = s[a:b]
		f = ss[0]
		l = ss[-1]
		nd = 0
		for i in range(0, a):
			if s[i] == f:
				nd = 1
				break
		if nd == 0:
			for i in range(b, n):
				if s[i] == l:
					nd = 1
					break
		if nd:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input()
	for q in range(q):
		(left, right) = map(int, input().split())
		left -= 1
		right -= 1
		flag = True
		prev = -1
		for c in s[left:right + 1]:
			i = s.find(c, prev + 1)
			if i == -1:
				print('NO')
				break
			if prev != i - 1 and prev != -1:
				flag = False
			prev = i
		else:
			if flag and s.find(s[right], prev + 1) == -1:
				print('NO')
			else:
				print('YES')


import random, math, sys, os, heapq
from bisect import bisect_left, bisect_right
from collections import Counter
from io import BytesIO, IOBase
input = sys.stdin.readline

def solution(n, q, s):
	exists0 = [0] * n
	exists1 = [0] * n
	prev0 = [0] * n
	prev1 = [0] * n
	f = False
	for i in range(n - 1, -1, -1):
		if s[i] == '0' or f:
			exists0[i] = 1
			f = True
	f = False
	for i in range(n - 1, -1, -1):
		if s[i] == '1' or f:
			exists1[i] = 1
			f = True
	f = False
	for i in range(n):
		if s[i] == '0' or f:
			prev0[i] = 1
			f = True
	f = False
	for i in range(n):
		if s[i] == '1' or f:
			prev1[i] = 1
			f = True
	for i in range(q):
		(l, r) = map(int, input().strip().split(' '))
		if r != n:
			if s[r - 1] == '1':
				if exists1[r]:
					print('YES')
					continue
			elif exists0[r]:
				print('YES')
				continue
		if l != 1:
			if s[l - 1] == '1':
				if prev1[l - 2]:
					print('YES')
					continue
			elif prev0[l - 2]:
				print('YES')
				continue
		print('NO')

def input_test():
	for _ in range(int(input())):
		(n, q) = map(int, input().strip().split(' '))
		s = input().strip()
		solution(n, q, s)

def test():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
input_test()


ans = []
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for _ in range(q):
		(li, ri) = [int(x) - 1 for x in input().split()]
		g1 = s.index(s[li]) != li
		g2 = s.rindex(s[ri]) != ri
		if g1 or g2:
			ans += ['YES']
		else:
			ans += ['NO']
print('\n'.join(ans))


import bisect
import math

def solve(n, q, s, qs):
	ans = []
	for j in range(q):
		l = qs[j][0]
		r = qs[j][1]
		req = s[l - 1:r]
		ptr = 0
		isconti = True
		isans = False
		for z in range(n):
			if req[ptr] == s[z]:
				isans = True
				if ptr == r - l and isconti:
					isconti = False
					continue
				ptr += 1
				if ptr == r - l + 1:
					break
			elif isans:
				isconti = False
				pass
		if ptr == r - l + 1 and isconti is False:
			ans.append('YES')
		else:
			ans.append('NO')
	return ans
	pass
t = int(input())
ans = []
for i in range(t):
	nq = [int(x) for x in input().split()]
	n = nq[0]
	q = nq[1]
	s = list(input())
	qs = []
	for j in range(q):
		arr = [int(x) for x in input().split()]
		qs.append(arr)
	ans.append(solve(n, q, s, qs))
for test in ans:
	for ele in test:
		print(ele)


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(x, y) = map(int, input().split())
		sub = s[x - 1:y]
		found = False
		j = 0
		if sub[0] in s[:x - 1]:
			found = True
		elif sub[-1] in s[y:]:
			found = True
		if found:
			print('YES')
		else:
			print('NO')


import itertools
import math
import sys
import os
from collections import defaultdict

def is_debug():
	return 'PYPY3_HOME' not in os.environ

def stdin_wrapper():
	data = '2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n2 3\n'
	for line in data.split('\n'):
		yield line
if not is_debug():

	def stdin_wrapper():
		while True:
			yield sys.stdin.readline()
inputs = stdin_wrapper()

def input_wrapper():
	return next(inputs)

def get_str():
	if is_debug():
		return input_wrapper()
	return input()

def get(_type):
	if _type == str:
		return get_str()
	return _type(input_wrapper())

def get_arr(_type):
	return [_type(x) for x in input_wrapper().split()]

def tuplerize(method):

	def wrap(*args, **kwargs):
		res = method(*args, **kwargs)
		if not isinstance(res, (tuple, list)):
			res = (res,)
		return res
	return wrap

@tuplerize
def solve(n, s, l, r):
	l -= 1
	sub = s[l:r]
	left_side = s[:l]
	right_side = s[r:]
	if not left_side and (not right_side):
		return 'NO'
	if sub[0] in left_side or sub[-1] in right_side:
		return 'YES'
	return 'NO'
t = get(int)
for _ in range(t):
	(n, q) = get_arr(int)
	s = get_str()
	for _ in range(q):
		(l, r) = get_arr(int)
		print(*solve(n, s, l, r))


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(n, q) = read_ints()
	s = input()
	for i in range(q):
		(l, r) = read_ints()
		if l > 1 and s[l - 1] in s[:l - 1] or (r < n and s[r - 1] in s[r:]):
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input().strip()
	for i in range(q):
		(a, b) = map(int, input().split())
		f = 0
		for j in s[b:]:
			if j == s[b - 1]:
				f = 1
		for j in s[:a - 1]:
			if j == s[a - 1]:
				f = 1
		if f:
			print('YES')
		else:
			print('NO')


from sys import stdout, stdin, maxsize
from collections import defaultdict, deque
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	s = input()
	for i in range(m):
		(u, v) = map(int, input().split())
		if v < n:
			if s[v - 1] in s[v:]:
				print('YES')
				continue
		if u > 0:
			if s[u - 1] in s[:u - 1]:
				print('YES')
				continue
		print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		fl = 0
		for j in range(l):
			if s[j] == s[l]:
				fl = 1
		for j in range(r + 1, n):
			if s[j] == s[r]:
				fl = 1
		if fl:
			print('YES')
		else:
			print('NO')


t = int(input())
for j in range(t):
	(n, q) = list(map(int, input().split()))
	s = input()
	mf = {}
	for l in range(q):
		(p, m) = list(map(int, input().split()))
		p -= 1
		m -= 1
		x = 0
		y = len(s) - 1
		r = False
		while True:
			if x >= p and y <= m:
				break
			if s[x] == s[p] and x < p:
				r = True
				break
			elif s[y] == s[m] and y > m:
				r = True
				break
			x += 1
			y -= 1
		if r and m - p + 1 >= 2:
			print('YES')
		else:
			print('NO')


import sys
import math

def scan(input_type='int'):
	if input_type == 'int':
		return list(map(int, sys.stdin.readline().strip().split()))
	else:
		return list(map(str, sys.stdin.readline().strip()))

def solution():
	for _ in range(int(input())):
		(n, q) = scan()
		s = scan('str')
		for __ in range(q):
			(l, r) = scan()
			a = n - 1
			b = 0
			d = s[l - 1:r]
			for i in range(n):
				if s[i] == d[0]:
					a = i
					break
			for i in range(n - 1, -1, -1):
				if s[i] == d[-1]:
					b = i
					break
			if a < l - 1 or b > r - 1:
				print('YES')
			else:
				print('NO')
solution()


for t in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for _ in range(q):
		(l, r) = map(int, input().split())
		if s[l - 1] in s[:l - 1] or s[r - 1] in s[r:]:
			print('YES')
		else:
			print('NO')


import sys
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	(n, q) = inp()
	a = str(input())
	for i in range(q):
		(l, r) = inp()
		l -= 1
		print('YES' if a[l] in a[:l] or a[r - 1] in a[r:] else 'NO')


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	s = input()
	for _1 in range(p):
		(l, r) = map(int, input().split())
		if s[:l - 1].find(s[l - 1]) != -1 or s[r:].find(s[r - 1]) != -1:
			print('YES')
		else:
			print('NO')


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	t = int(input())
	ans_a = []
	for ti in range(t):
		(n, q) = map(int, input().split())
		s = [-1] + list(map(int, input().rstrip())) + [-1]
		index = [[10 ** 9, -1], [10 ** 9, -1]]
		for i in range(1, n + 1):
			index[s[i]][0] = min(index[s[i]][0], i)
			index[s[i]][1] = max(index[s[i]][1], i)
		for _ in range(q):
			(l, r) = map(int, input().split())
			if index[s[l]][0] < l or r < index[s[r]][1]:
				ans_a.append('YES')
			else:
				ans_a.append('NO')
	output(*ans_a)
main()


t = int(input())
for i in range(t):
	(n, q) = map(int, input().split())
	s = input()
	for j in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		finds = s[l:r]
		flag = 0
		if s.find(finds[0], 0, l) > -1 and flag == 0:
			flag = 1
		if s.find(finds[-1], r) > -1 and flag == 0:
			flag = 1
		if flag == 1:
			print('YES')
		else:
			print('NO')


res = ''
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input().strip()
	for __ in range(q):
		(l, r) = map(int, input().split())
		first_char = s[l - 1]
		last_char = s[r - 1]
		success = False
		for i in range(l - 1):
			if s[i] == first_char:
				success = True
				break
		if not success:
			for i in range(r, n):
				if s[i] == last_char:
					success = True
					break
		if success:
			res += 'YES\n'
		else:
			res += 'NO\n'
print(res)


get = input
func = len

def solve():
	(l, q) = list(map(int, get().split()))
	string = get()
	(check1, check2) = (False, False)
	for i in range(q):
		(a, b) = list(map(int, get().split()))
		if b - a + 1 == l:
			print('NO')
		else:
			for i in range(0, a - 1):
				if string[i] == string[a - 1]:
					print('YES')
					check1 = True
					break
			if check1 == False:
				for i in range(b, l):
					if string[i] == string[b - 1]:
						print('YES')
						check2 = True
						break
			if check1 == False and check2 == False:
				print('NO')
			(check1, check2) = (False, False)
for i in range(int(get())):
	solve()


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = list(input())
	for i in range(q):
		(l, r) = map(int, input().split())
		f = 0
		for j in range(l - 1):
			if s[j] == s[l - 1]:
				f = 1
				break
		for j in range(r, n):
			if s[j] == s[r - 1]:
				f = 1
				break
		if f == 1:
			print('YES')
		else:
			print('NO')


import sys
sys.setrecursionlimit(10 ** 5)
input = lambda : sys.stdin.readline().strip()
inp = lambda : list(map(int, sys.stdin.readline().strip().split()))

def check(a, b):
	n = len(a)
	m = len(b)
	i = j = 0
	while i < n and j < m:
		if a[i] == b[j]:
			j += 1
		i += 1
		if j == m:
			break
	return True if j == m else False
for _ in range(int(input())):
	(n, q) = inp()
	s = str(input())
	one = s.count('1')
	zer = s.count('0')
	for kk in range(q):
		(l, r) = inp()
		m = r + 1 - l
		t = s[l - 1:r]
		ans = 0
		for i in range(l - 1, r):
			new = s[:i] + s[i + 1:]
			lol = check(new, t)
			if lol == True:
				ans += 1
		if ans > 0:
			print('YES')
		else:
			print('NO')


N = int(input())
for _ in range(N):
	(n, q) = map(int, input().split())
	s = input()
	for __ in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		res = False
		for i in range(l):
			if s[i] == s[l]:
				res = True
		for i in range(r + 1, len(s)):
			if s[i] == s[r]:
				res = True
		if res:
			print('YES')
		else:
			print('NO')


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


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	zero_left = [False] * n
	zero_right = [False] * n
	one_left = [False] * n
	one_right = [False] * n
	for i in range(n):
		if s[i] == '0' or (i and zero_left[i - 1]):
			zero_left[i] = True
		if s[i] == '1' or (i and one_left[i - 1]):
			one_left[i] = True
	for i in range(n - 1, -1, -1):
		if s[i] == '0' or (i < n - 1 and zero_right[i + 1]):
			zero_right[i] = True
		if s[i] == '1' or (i < n - 1 and one_right[i + 1]):
			one_right[i] = True
	for i in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		ans = 'NO'
		if l:
			if s[l] == '0':
				if zero_left[l - 1]:
					ans = 'YES'
			elif one_left[l - 1]:
				ans = 'YES'
		if r < n - 1:
			if s[r] == '0':
				if zero_right[r + 1]:
					ans = 'YES'
			elif one_right[r + 1]:
				ans = 'YES'
		print(ans)


N = int(input())
for i in range(N):
	(a, n) = map(int, input().split())
	s = input()
	for i in range(n):
		flag = False
		(l, r) = map(int, input().split())
		parte1 = s[0:l - 1]
		parte2 = s[r:]
		tmp = s[l - 1:r]
		if parte1.find(tmp[0]) != -1 or parte2.find(tmp[-1]) != -1:
			flag = True
		if flag:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = [int(x) for x in input().split()]
	s = input()
	for i in range(q):
		(l, r) = [int(x) for x in input().split()]
		if l == 1 and r == n:
			print('NO')
		else:
			flag = False
			flag1 = False
			s1 = s[l - 1:r]
			k = len(s1)
			for j in range(0, l - 1):
				if s[j] == s1[0]:
					flag1 = True
					flag = True
					break
			if flag == False:
				for j in range(r, len(s)):
					if s[j] == s1[len(s1) - 1]:
						flag1 = True
						break
			if flag1 == True:
				print('YES')
			else:
				print('NO')


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(s, x, y):
	if s[x - 1] in s[:x - 1] or s[y - 1] in s[y:]:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	(n, q) = get_int()
	s = str(input()[:-1])
	for i in range(q):
		(x, y) = get_int()
		solve(s, x, y)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

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

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, Q) = In()
		s = input()
		(no1, no0) = (0, 0)
		(pre1, pre0) = ([], [])
		for i in range(n):
			if s[i] == '1':
				no1 += 1
			else:
				no0 += 1
			pre1.append(no1)
			pre0.append(no0)
		for q in range(Q):
			(a, b) = In()
			flag = 0
			a -= 1
			b -= 1
			for i in range(a - 1, -1, -1):
				if s[i] == s[a]:
					flag = 1
					break
			if flag == 0:
				for i in range(b + 1, n):
					if s[i] == s[b]:
						flag = 1
						break
			if flag:
				yes()
			else:
				no()
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = str(input())
	for i in range(q):
		(l, r) = map(int, input().split())
		p = s[l - 1:r]
		if s[l - 1] in s[:l - 1] or s[r - 1] in s[r:]:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(l, r) = map(int, input().split())
		good = False
		for i in range(0, l - 1):
			if s[i] == s[l - 1]:
				good = True
				break
		if good:
			print('YES')
		else:
			for i in range(r, n):
				if s[i] == s[r - 1]:
					good = True
					break
			if good:
				print('YES')
			else:
				print('NO')


for t in range(int(input())):
	(n, q) = map(int, input().split())
	s = str(input())
	lst = list(s)
	for j in range(q):
		(l, r) = map(int, input().split())
		if lst[l - 1] in lst[:l - 1] or lst[r - 1] in lst[r:]:
			print('YES')
		else:
			print('NO')


output_list = list()

def answer(req_string, req_list):
	length = len(req_string)
	for indices in req_list:
		start = int(indices[0]) - 1
		end = int(indices[1]) - 1
		if end - start + 1 == length:
			output_list.append('NO')
			continue
		if string[start] in string[:start] or string[end] in string[end + 1:]:
			output_list.append('YES')
			continue
		output_list.append('NO')
num_test = int(input())
i = 0
while i < num_test:
	(a, b) = input().split()
	len_string = int(a)
	num_queries = int(b)
	j = 0
	string = input()
	substring_indices = list()
	while j < num_queries:
		substring_indices.append(input().split())
		j = j + 1
	answer(string, substring_indices)
	i = i + 1
for item in output_list:
	print(item)


import sys
import math
import collections
import bisect

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, q) = get_ints()
	string = list(get_string())
	for i in range(q):
		(l, r) = get_ints()
		sub_string = string[l - 1:r]
		last = sub_string[-1]
		search_string = string[r:]
		poss = 0
		if last in search_string:
			poss += 1
		first = sub_string[0]
		search_string = string[:l - 1]
		if first in search_string:
			poss += 1
		if poss > 0:
			print('YES')
		else:
			print('NO')


import bisect
import math
import collections
import sys
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())

def solution():
	t = inp()
	for _ in range(t):
		(_, n) = inlt()
		s = input()
		solve(s, n)

def solve(s, n):
	first = [-1] * 2
	last = [-1] * 2
	for (i, c) in enumerate(s[:-1]):
		if c == '0':
			if first[0] < 0:
				first[0] = i
			last[0] = i
		else:
			if first[1] < 0:
				first[1] = i
			last[1] = i
	for _ in range(n):
		(a, b) = inlt()
		if a - 1 in first and b - 1 in last:
			print('NO')
		else:
			print('YES')
solution()


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_string():
	return list(map(str, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_print_int(x):
	sys.stdout.write(str(x) + '\n')

def get_print(x):
	sys.stdout.write(x + '\n')

def solve():
	for _ in range(get_int()):
		(n, q) = get_ints()
		s = get_string()
		while q:
			(l, r) = get_ints()
			if s[l - 1] in s[:l - 1] or s[r - 1] in s[r:]:
				get_print('YES')
			else:
				get_print('NO')
			q -= 1
solve()


import random

def main():
	t = int(input())
	for _ in range(t):
		(n, q) = list(map(int, input().split()))
		s = input()
		zs = 0
		os = 0
		ze = 0
		oe = 0
		for i in range(n):
			if s[i] == '0':
				zs = i + 1
				break
		for i in range(n):
			if s[i] == '1':
				os = i + 1
				break
		for i in reversed(range(n)):
			if s[i] == '0':
				ze = i + 1
				break
		for i in reversed(range(n)):
			if s[i] == '1':
				oe = i + 1
				break
		for _ in range(q):
			(l, r) = list(map(int, input().split()))
			if s[l - 1] == '0' and zs < l:
				print('YES')
			elif s[l - 1] == '1' and os < l:
				print('YES')
			elif s[r - 1] == '1' and oe > r:
				print('YES')
			elif s[r - 1] == '0' and ze > r:
				print('YES')
			else:
				print('NO')
main()


try:
	test = int(input())
	while test != 0:
		(n, q) = map(int, input().split())
		string = input()
		for i in range(q):
			(left, right) = map(int, input().split())
			new_string = string[left - 1:right]
			forward = string[:left - 1]
			backward = string[right:]
			flag = False
			if forward != '':
				for i in range(len(forward)):
					if forward[i] == new_string[0]:
						flag = True
						print('YES')
						break
			if backward != '' and (not flag):
				for i in range(len(backward)):
					if new_string[-1] == backward[i]:
						flag = True
						print('YES')
						break
			if not flag:
				print('NO')
		test -= 1
except EOFError as e:
	print('')


for _ in range(int(input())):
	(n, q) = input().split()
	(n, q) = (int(n), int(q))
	s = input()
	for kk in range(q):
		(i, j) = input().split()
		(i, j) = (int(i), int(j))
		f1 = f2 = 0
		sub = s[i - 1:j]
		if sub[-1] in s[j:]:
			f1 = 1
		if sub[0] in s[:i - 1]:
			f2 = 1
		if f1 == 1 or f2 == 1:
			print('YES')
		else:
			print('NO')


import sys
import bisect
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
for T in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for Q in range(q):
		(l, r) = map(int, input().split())
		fir = s[l - 1]
		sec = s[r - 1]
		found = False
		for i in range(0, l - 1):
			if s[i] == fir:
				found = True
				break
		if found == False:
			for i in range(r, n):
				if s[i] == sec:
					found = True
					break
		if found:
			print('YES')
		else:
			print('NO')


def f():
	t = int(input())
	for i in range(t):
		temp = input()
		temp = temp.split(' ')
		n = int(temp[0])
		q = int(temp[1])
		s = input()
		for i in range(q):
			x = -1
			y = -1
			res = input()
			res = res.split(' ')
			res = map(int, res)
			res = list(res)
			l = res[0] - 1
			r = res[1] - 1
			if r - l + 1 < 2 or r - l + 1 == len(s):
				print('NO')
			elif l > 0 and r < len(s) - 1:
				for k in range(l):
					if s[k] == s[l]:
						x = k
						print('YES')
						break
				if x == -1:
					for k in range(r + 1, len(s)):
						if s[k] == s[r]:
							y = k
							print('YES')
							break
				if x == -1 and y == -1:
					print('NO')
			elif l == 0:
				for k in range(r + 1, len(s)):
					if s[k] == s[r]:
						y = k
						print('YES')
						break
				if y == -1:
					print('NO')
			elif r == len(s) - 1:
				for k in range(l):
					if s[k] == s[l]:
						x = k
						print('YES')
						break
				if x == -1:
					print('NO')
f()


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	array = input()
	for i in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		i = l
		j = 0
		flag = 0
		flag2 = 0
		flag3 = 0
		while i < r:
			if j == n:
				break
			if array[j] == array[i]:
				flag3 = 1
				j += 1
				i += 1
			else:
				if flag3 == 1:
					flag2 = 1
				j += 1
		if flag2 == 0:
			j += 1
		while j < n:
			if array[j] == array[r]:
				flag = 1
				break
			j += 1
		if flag == 0:
			print('NO')
		else:
			print('YES')


def word():
	return input()

def words():
	return [word for word in input().split()]

def number():
	return int(input())

def numbers():
	return [int(item) for item in input().split()]

def dump(lst):
	for (i, item) in enumerate(lst):
		print(i, item)

def binsearch(arr, a, b):
	m = (a + b) // 2
	if a >= b:
		return a - 1 if arr[a] == 0 else a
	return binsearch(arr, a, m - 1) if arr[m] == 0 else binsearch(arr, m + 1, b)

def f(a, i, j):
	return 'YES' if a[i] in a[0:i] or a[j] in a[j + 1:] else 'NO'
for t in range(number()):
	(n, q) = numbers()
	a = word()
	arr = [numbers() for i in range(q)]
	for (i, j) in arr:
		print(f(a, i - 1, j - 1))


t = int(input())
for l in range(t):
	(n, q) = [int(x) for x in input().split(' ')]
	s = input()
	B = []
	C = []
	u = 0
	v = 0
	for i in range(n):
		if s[i] != s[0] and u == 0:
			u = i
		if s[i] != s[n - 1] and v < i:
			v = i
	firsts = [0, u]
	lasts = [v, n - 1]
	for m in range(q):
		(a, b) = [int(x) for x in input().split(' ')]
		if a - 1 in firsts and b - 1 in lasts:
			print('NO')
		else:
			print('YES')


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(a, b) = map(int, input().split())
		if s[a - 1] in s[0:a - 1] or s[b - 1] in s[b:]:
			print('YES')
		else:
			print('NO')


def bounds(s):
	(f0, f1) = (None, None)
	for i in range(len(s)):
		if s[i] == '0' and f0 is None:
			f0 = i
		if s[i] == '1' and f1 is None:
			f1 = i
	(l0, l1) = (None, None)
	for i in range(len(s) - 1, -1, -1):
		if s[i] == '0' and l0 is None:
			l0 = i
		if s[i] == '1' and l1 is None:
			l1 = i
	return ({'0': f0, '1': f1}, {'0': l0, '1': l1})
for _ in range(int(input())):
	(n, q) = [int(x) for x in input().split()]
	s = input()
	(f, la) = bounds(s)
	for i in range(q):
		(l, r) = [int(x) for x in input().split()]
		if f[s[l - 1]] < l - 1 or r - 1 < la[s[r - 1]]:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, q) = list(map(int, input().split()))
	s = input()
	for i in range(q):
		ans = 0
		lock = True
		arr = list(map(int, input().split()))
		if not abs(arr[0] - arr[1]) >= 1:
			ans = 0
		else:
			if arr[0] > 1:
				for i in range(0, arr[0] - 1):
					if s[i] == s[arr[0] - 1]:
						ans = 1
						lock = False
						break
				else:
					ans = 0
			if arr[1] < len(s) + 1 and lock == True:
				for i in range(arr[1], len(s)):
					if s[i] == s[arr[1] - 1]:
						ans = 1
						break
				else:
					ans = 0
		if ans == 0:
			print('NO')
		else:
			print('YES')


def match(char, encode):
	if encode == 3:
		return True
	elif char == '1' and encode == 1:
		return True
	elif char == '0' and encode == 2:
		return True
	else:
		return False
for i in range(int(input())):
	(n, q) = list(map(int, input().split()))
	s = input()
	reverse_s = s[::-1]
	encode_left = [0] * n
	encode_left[1] = 1 if s[0] == '1' else 2
	for i in range(2, n):
		if encode_left[i - 1] == 3:
			encode_left[i] = 3
		else:
			encode_left[i] = 3 if s[i - 1] != s[i - 2] else encode_left[i - 1]
	encode_right = [0] * n
	encode_right[1] = 1 if reverse_s[0] == '1' else 2
	for i in range(2, n):
		if encode_right[i - 1] == 3:
			encode_right[i] = 3
		else:
			encode_right[i] = 3 if reverse_s[i - 1] != reverse_s[i - 2] else encode_right[i - 1]
	encode_right = encode_right[::-1]
	for i in range(q):
		(l, r) = list(map(int, input().split()))
		left_char = s[l - 1]
		right_char = s[r - 1]
		print('YES') if match(left_char, encode_left[l - 1]) or match(right_char, encode_right[r - 1]) else print('NO')


def isSubstringSubsequence(s, n, l, r):
	first = s[l - 1]
	second = s[r - 1]
	if first in s[:l - 1]:
		return True
	if second in s[r:]:
		return True
	return False
t = int(input())
while t:
	(n, q) = map(int, input().split())
	s = input()
	while q:
		(l, r) = map(int, input().split())
		if isSubstringSubsequence(s, n, l, r):
			print('YES')
		else:
			print('NO')
		q -= 1
	t -= 1


def solve():
	(n, q) = map(int, input().split())
	s = input()
	for ppp in range(q):
		(l, r) = map(int, input().split())
		start = s[l - 1]
		end = s[r - 1]
		(st, ed) = (False, False)
		for i in range(l - 1):
			if s[i] == start:
				st = True
				break
		for i in range(r, n):
			if s[i] == end:
				ed = True
				break
		if st or ed:
			print('YES')
		else:
			print('NO')
for _ in range(int(input())):
	solve()


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint

def main():
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(l, r) = map(lambda x: int(x) - 1, input().split())
		bol = False
		for i in range(l):
			if s[i] == s[l]:
				bol = True
		for i in range(r + 1, n):
			if s[i] == s[r]:
				bol = True
		if bol:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	main()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = [0] + list(input())
	d = [list(map(int, input().split())) for _ in range(q)]
	for i in range(q):
		flag = False
		(l, r) = d[i]
		for j in range(1, l):
			if s[l] == s[j]:
				flag = True
				break
		for j in range(r + 1, n + 1):
			if s[r] == s[j]:
				flag = True
				break
		print('YES' if flag else 'NO')


def is_good_subsequence(line, ini, fim):
	i = 0
	j = len(line) - 1
	while i != ini or j != fim:
		if i != ini and line[i] == line[ini]:
			return True
		if j != fim and line[j] == line[fim]:
			return True
		if i < ini:
			i += 1
		if j > fim:
			j -= 1
	return False
t = int(input())
for i in range(t):
	(n, q) = list((int(num) for num in input().split(' ')))
	line = input()
	for j in range(q):
		(ini, fim) = list((int(num) for num in input().split(' ')))
		if is_good_subsequence(line, ini - 1, fim - 1):
			print('YES')
		else:
			print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	(n, q) = map(int, input().split())
	s = input()
	for _ in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		if s[:l].count(s[l]) or s[r:].count(s[r - 1]):
			print('YES')
		else:
			print('NO')


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, q) = map(int, input().split())
	s = input()
	c0 = s.count('0')
	c1 = s.count('1')
	while q:
		q -= 1
		(l, r) = map(int, input().split())
		l -= 1
		ff = 0
		k = s[l:r]
		if s[l] in s[0:l]:
			ff = 1
		if s[r - 1] in s[r:]:
			ff = 1
		if ff:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	f = 1
	for i in range(q):
		(l, r) = map(int, input().split())
		x = s[l - 1]
		y = s[r - 1]
		if x in s[0:l - 1] or y in s[r:len(s)]:
			print('YES')
		else:
			print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
for _ in range(ii()):
	(n, q) = mi()
	s = si()
	ans = ['YES', 'NO']
	flag = 0
	for i in range(q):
		(l, r) = mi()
		if s[l - 1] in s[0:l - 1] or s[r - 1] in s[r:]:
			flag = 0
		else:
			flag = 1
		print(ans[flag])


import sys, os, io
from collections import deque
for _ in range(int(input())):
	(n, q) = [int(i) for i in input().split()]
	s = input()
	l0 = n
	l1 = n
	r0 = -1
	r1 = -1
	if '0' in s:
		l0 = s.index('0')
		r0 = n - 1 - s[::-1].index('0')
	if '1' in s:
		l1 = s.index('1')
		r1 = n - 1 - s[::-1].index('1')
	for i in range(q):
		(l, r) = [int(i) - 1 for i in input().split()]
		c = s[l:r + 1]
		flag = 0
		if c[0] == '1':
			if l1 < l:
				flag = 1
		elif l0 < l:
			flag = 1
		if c[-1] == '1':
			if r1 > r:
				flag = 1
		elif r0 > r:
			flag = 1
		if flag:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for j in range(q):
		(l, r) = map(int, input().split())
		if abs(r - l) == 0:
			print('NO')
			break
		index = l - 1
		flag = False
		ff = False
		last_index = s.index(s[index])
		for k in range(n):
			if ff:
				ff = False
				continue
			if s[k] == s[index]:
				index += 1
				if k - last_index > 1:
					flag = True
				last_index = k
				if index == r - 1 and (not flag):
					ff = True
				if index == r:
					break
		if r == index and flag:
			print('YES')
		else:
			print('NO')


def isNewSubseq(l, r, s):
	n = len(s)
	i = 0
	prev = -1
	isNoGap = True
	ans = False
	while i < n:
		if s[i] == s[l]:
			if prev != -1 and isNoGap and (i - prev > 1):
				isNoGap = False
			prev = i
			l += 1
			if not l < r:
				break
		i += 1
	if isNoGap:
		i += 2
	while i < n:
		if s[i] == s[r]:
			ans = True
			break
		i += 1
	return ans
t = int(input())
while t:
	(n, q) = map(int, input().split(' '))
	s = input()
	ans = -1
	for i in range(q):
		(l, r) = map(int, input().split(' '))
		ans = False
		l -= 1
		r -= 1
		for j in range(l):
			if s[j] == s[l]:
				ans = True
				break
		if not ans:
			for j in range(r + 1, n):
				if s[j] == s[r]:
					ans = True
					break
		if ans:
			print('YES')
		else:
			print('NO')
	t -= 1


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = list(input())
	for _ in range(q):
		(l, r) = map(int, input().split())
		subs = s[l - 1:r]
		ch1 = s[l - 1]
		ch2 = s[r - 1]
		if ch1 in s[:l - 1] or ch2 in s[r:]:
			print('YES')
		else:
			print('NO')


from sys import stdin, stdout

def solve():
	(n, q) = map(int, input().split())
	s = input()
	assert n == len(s)
	bits = [[0, 0] for _ in range(n)]
	count_1 = 0
	count_0 = 0
	for i in range(n):
		if s[i] == '0':
			count_0 += 1
		else:
			count_1 += 1
		bits[i][0] = count_0
		bits[i][1] = count_1
	for _ in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		left_most_bit = int(s[l])
		right_most_bit = int(s[r])
		if l > 0:
			if bits[l - 1][left_most_bit] > 0:
				print('YES')
				continue
		if r < n - 1:
			if bits[n - 1][right_most_bit] - bits[r][right_most_bit] > 0:
				print('YES')
				continue
		print('NO')

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


from io import BytesIO, IOBase
import sys
import math
import os
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def solve():
	(l, n) = map(int, input().split())
	s = input()
	for _ in range(n):
		(l, r) = map(int, input().split())
		if s[r - 1] in s[r:] or s[l - 1] in s[:l - 1]:
			print('YES')
		else:
			print('NO')

def main():
	for _ in range(int(input())):
		solve()
main()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
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 gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def lcm(a, b):
	return abs(a // gcd(a, b) * b)

def solve():
	(n, q) = sep()
	s = inp()
	for _ in range(q):
		(l, r) = sep()
		l -= 1
		a = s[:l]
		b = s[r:]
		if s[l] in a:
			YES()
			continue
		if s[r - 1] in b:
			YES()
			continue
		NO()
testcase(int(inp()))


s = '001000'
l = 2
r = 4

def answer(s, l, r):
	ind = 0
	while ind < l - 1:
		if s[ind] == s[l - 1]:
			return 'YES'
		ind += 1
	ind = len(s) - 1
	while ind > r - 1:
		if s[ind] == s[r - 1]:
			return 'YES'
		ind -= 1
	return 'NO'
t = int(input())
for m in range(t):
	inp = input().split()
	q = int(inp[1])
	s = input()
	for n in range(q):
		inp = input().split()
		l = int(inp[0])
		r = int(inp[1])
		print(answer(s, l, r))


t = int(input())
for k in range(t):
	(j, q) = list(map(int, input().split()))
	s = list(map(int, list(input())))
	for i in range(q):
		(l, r) = list(map(int, input().split()))
		l -= 1
		r -= 1
		verdict = ''
		if s[l] in s[0:l] and l != 0:
			verdict = 'YES'
		elif s[r] in s[r + 1:] and r != j - 1:
			verdict = 'YES'
		else:
			verdict = 'NO'
		print(verdict)


t = int(input())
for i in range(t):
	(n, q) = map(int, input().split())
	s = input()
	li = []
	for i in range(n):
		li.append(s[i])
	for i in range(q):
		(l, r) = map(int, input().split())
		if s[:l - 1].count(s[l - 1]) > 0:
			print('YES')
		elif s[r:].count(s[r - 1]) > 0:
			print('YES')
		else:
			print('NO')


def main():
	t = int(input())
	for _ in range(t):
		(n, q) = map(int, input().split())
		s = input()
		next_forward = [[], []]
		next_backward = [[], []]
		latest = [-1, -1]
		for i in range(n):
			next_backward[0].append(latest[0])
			next_backward[1].append(latest[1])
			next_forward[0].append(-1)
			next_forward[1].append(-1)
			if s[i] == '0':
				latest[0] = i
			else:
				latest[1] = i
		latest = [-1, -1]
		for j in range(n - 1, -1, -1):
			next_forward[0][j] = latest[0]
			next_forward[1][j] = latest[1]
			if s[j] == '0':
				latest[0] = j
			else:
				latest[1] = j
		for __ in range(q):
			(l, r) = map(int, input().split())
			prev_first = next_backward[int(s[l - 1])][l - 1]
			next_last = next_forward[int(s[r - 1])][r - 1]
			if prev_first == next_last == -1:
				print('NO')
			else:
				print('YES')
main()


import os
from io import BytesIO
from math import *

def main():
	t = int(input())
	for _ in range(t):
		(n, q) = list(map(int, input().split()))
		s = input()
		for _ in range(q):
			(l, r) = list(map(int, input().split()))
			left_char = s[l - 1]
			right_char = s[r - 1]
			if str(left_char) in s[:l - 1] or str(right_char) in s[r:]:
				print('YES')
			else:
				print('NO')
main()


t = int(input())
for _ in range(t):
	list1 = list(map(int, input().split()))
	seq = input()
	for _ in range(list1[1]):
		(l, r) = map(int, input().split())
		if seq[l - 1] in seq[:l - 1] or seq[r - 1] in seq[r:]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = str(input())
	for i in range(q):
		(a, b) = map(int, input().split())
		l1 = []
		c = a - 1
		tt = 0
		tot = 0
		count = 0
		for j in range(len(s)):
			if s[j] == s[c]:
				k = j
				c += 1
				count += 1
			if c == b - 1:
				tt = 1
				break
		c = b - 1
		for w in range(len(s) - 1, -1, -1):
			if s[w] == s[c]:
				c -= 1
				count += 1
			if c == a - 1:
				tot = 1
				break
		if tt == 1:
			for k in range(j + 2, len(s)):
				if s[k] == s[b - 1]:
					tt = 0
					break
			if tt == 0:
				print('YES')
				continue
		if tot == 1:
			for k in range(w - 2, -1, -1):
				if s[k] == s[a - 1]:
					tot = 0
					break
			if tot == 0:
				print('YES')
				continue
		if tot == 1 or tt == 1:
			print('NO')


t = int(input())
for idx in range(t):
	(str_len, qnum) = map(int, input().split(' '))
	ostr = input()
	cnt_d = dict()
	rcnt_d = dict()
	flag_0 = False
	flag_1 = False
	for pos in range(str_len):
		cnt_d[pos] = {0: False, 1: False}
		if '0' == ostr[pos] or flag_0 == True:
			cnt_d[pos][0] = True
			flag_0 = True
		if '1' == ostr[pos] or flag_1 == True:
			cnt_d[pos][1] = True
			flag_1 = True
	flag_0 = False
	flag_1 = False
	for pos in range(str_len - 1, -1, -1):
		rcnt_d[pos] = {0: False, 1: False}
		if '0' == ostr[pos] or flag_0 == True:
			rcnt_d[pos][0] = True
			flag_0 = True
		if '1' == ostr[pos] or flag_1 == True:
			rcnt_d[pos][1] = True
			flag_1 = True
	for idx2 in range(qnum):
		(l, r) = map(int, input().split(' '))
		l = l - 1
		r = r - 1
		c_l = ostr[l:l + 1]
		c_r = ostr[r:r + 1]
		if l > 0 and cnt_d[l - 1][int(c_l)] or (r < str_len - 1 and rcnt_d[r + 1][int(c_r)]):
			print('YES')
		else:
			print('NO')


def solve(idxs, sub, s):
	if len(sub) < 2:
		return 'NO'
	dic = {}
	for (i, item) in enumerate(s):
		if item not in dic:
			dic[item] = [i]
		else:
			dic[item].append(i)
	if dic[sub[0]][0] < idxs[0] - 1 or dic[sub[-1]][-1] > idxs[1] - 1:
		return 'YES'
	return 'NO'

def calc(n, k, s, queries):
	for query in queries:
		print(solve(query, s[query[0] - 1:query[1]], s))
t = int(input())
for i in range(t):
	queries = []
	(n, k) = list(map(int, input().split()))
	s = input()
	for i in range(k):
		queries.append(list(map(int, input().split())))
	calc(n, k, s, queries)


t = int(input())
for i in range(t):
	(n, q) = [int(x) for x in input().split()]
	s = list(input())
	for i in range(q):
		(l, r) = [int(x) for x in input().split()]
		l -= 1
		r -= 1
		if s[l] in s[:l] or s[r] in s[r + 1:]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = list(map(int, input().split()))
	string = list(input())
	flag = False
	for _ in range(q):
		flag = False
		(l, r) = list(map(int, input().split()))
		sl = string[l - 1]
		sr = string[r - 1]
		for i in range(len(string)):
			if i < l - 1 and string[i] == sl:
				flag = True
				break
			elif i > r - 1 and string[i] == sr:
				flag = True
				break
		if flag:
			print('YES')
		else:
			print('NO')


import math
for w in range(int(input())):
	(n, q) = tuple(map(int, input().split()))
	s = str(input())
	for q1 in range(q):
		(l, r) = tuple(map(int, input().split()))
		if l != 1 or r != n:
			if s[l - 1] in s[:l - 1]:
				print('YES')
			elif s[r - 1] in s[r:]:
				print('YES')
			else:
				print('NO')
		elif l == 1 and r == n:
			print('NO')
		elif l == 1:
			if s[r - 1] in s[r:]:
				print('YES')
			else:
				print('NO')
		elif s[l - 1] in s[:l - 1]:
			print('YES')
		else:
			print('NO')


test = int(input())
for _ in range(test):
	(n, q) = map(int, input().split())
	s = str(input())
	(l_zero, l_one, r_zero, r_one) = (0, 0, 0, 0)
	(l_freq, r_freq) = ([[] for _ in range(n)], [[] for _ in range(n)])
	for i in range(n):
		if s[i] == '1':
			l_one += 1
		else:
			l_zero += 1
		if s[n - i - 1] == '1':
			r_one += 1
		else:
			r_zero += 1
		l_freq[i] = [l_zero, l_one]
		r_freq[n - i - 1] = [r_zero, r_one]
	for _ in range(q):
		(a, b) = map(int, input().split())
		isTrue = False
		if s[a - 1] == '0' and l_freq[a - 1][0] > 1:
			isTrue = True
		elif s[a - 1] == '1' and l_freq[a - 1][1] > 1:
			isTrue = True
		elif s[b - 1] == '0' and r_freq[b - 1][0] > 1:
			isTrue = True
		elif s[b - 1] == '1' and r_freq[b - 1][1] > 1:
			isTrue = True
		if isTrue:
			print('YES')
		else:
			print('NO')


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = list(input())
	res = []
	for i in range(q):
		(l, r) = map(int, input().split())
		if l == 1 and r == n:
			res.append('NO')
		elif l == 1:
			if s[r - 1] in s[r:]:
				res.append('YES')
			else:
				res.append('NO')
		elif r == n:
			if s[l - 1] in s[0:l - 1]:
				res.append('YES')
			else:
				res.append('NO')
		elif s[r - 1] in s[r:] or s[l - 1] in s[0:l - 1]:
			res.append('YES')
		else:
			res.append('NO')
	for j in res:
		print(j)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, input().split())

def solve():
	(n, q) = mints()
	s = minp()
	a = [0] * n
	for t in range(q):
		(l, r) = mints()
		l -= 1
		p = int(s[0] == s[l])
		a[0] = p
		len = r - l
		for i in range(1, n):
			if p != len:
				p += s[i] == s[l + p]
			a[i] = p
		r -= 1
		p = int(s[-1] == s[r])
		if p != 0 and a[n - 3] != 0 and (n - 3 >= 0) and (a[n - 3] + p >= len):
			print('YES')
			continue
		for i in range(1, n):
			if p != len:
				p += s[n - i - 1] == s[r - p]
			if p != 0 and n - 3 - i >= 0 and (a[n - 3 - i] != 0) and (a[n - 3 - i] + p >= len):
				print('YES')
				break
		else:
			print('NO')
for i in range(mint()):
	solve()


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


from sys import stdin, stdout
t = int(stdin.readline())
for case in range(t):
	(n, q) = map(int, stdin.readline().split())
	ss = list(stdin.readline().strip())
	csum = [0] * (n + 1)
	for i in range(1, n + 1):
		csum[i] = csum[i - 1] + ord(ss[i - 1]) - ord('0')
	for qry in range(q):
		(left, right) = map(int, stdin.readline().split())
		ans = 'NO'
		if left == 1 and right == n:
			ans = 'NO'
		else:
			if left > 1:
				if ss[left - 1] == '0':
					if csum[left - 1] < left - 1:
						ans = 'YES'
				elif csum[left - 1] > 0:
					ans = 'YES'
			if right < n:
				if ss[right - 1] == '0':
					if csum[n] - csum[right] < n - right:
						ans = 'YES'
				elif csum[n] - csum[right] > 0:
					ans = 'YES'
		stdout.write('{}\n'.format(ans))


from sys import stdin, stdout

def II():
	return int(stdin.readline())

def SI():
	return stdin.readline()[:-1]

def MI():
	return map(int, stdin.readline().split())
yes = 'YES\n'
no = 'NO\n'

def solve():
	(n, q) = MI()
	s = SI()
	rs = s[::-1]
	for _ in range(q):
		(l, r) = MI()
		(l, r) = (l - 1, r - 1)
		j = s.find(s[l])
		k = n - 1 - rs.find(s[r])
		if l > j or k > r:
			stdout.write(yes)
		else:
			stdout.write(no)
t = II()
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input()
	for _ in range(q):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		left = False
		right = False
		for i in range(a):
			if s[i] == s[a]:
				left = True
		if left:
			print('YES')
			continue
		for i in range(b + 1, n):
			if s[b] == s[i]:
				right = True
		if right:
			print('YES')
		else:
			print('NO')


t = int(input())
for k in range(t):
	(n, q) = list(map(int, input().split()))
	s = input()
	for j in range(q):
		(l, r) = list(map(int, input().split()))
		w = ''
		m = s[l - 1:r]
		if len(m) == n:
			w = 'NO'
		elif m[-1] in s[r:]:
			w = 'YES'
		elif m[0] in s[0:l - 1]:
			w = 'YES'
		else:
			w = 'NO'
		print(w)


t = int(input())
for t in range(0, t):
	q = list(map(int, input().rstrip().split()))
	n = q[0]
	qu = q[1]
	str = input()
	for j in range(0, qu):
		a = list(map(int, input().rstrip().split()))
		l = a[0]
		r = a[1]
		st = str[l - 1:r]
		el = st[len(st) - 1]
		strrem = str[r:len(str)]
		if strrem.count(el) > 0:
			print('YES')
		else:
			ele = st[0]
			sti = str[0:l - 1]
			if sti.count(ele) > 0:
				print('YES')
			else:
				print('NO')


testcases = int(input())
for _ in range(testcases):
	(strlen, queries) = [int(i) for i in input().split()]
	s = input()
	for _ in range(queries):
		(sta, sto) = [int(i) for i in input().split()]
		substr = s[sta - 1:sto]
		(l, r) = (substr[0], substr[-1])
		before = s[:sta - 1]
		after = s[sto:]
		if l in before or r in after:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(l, n) = map(int, input().split())
	a = input()
	for _ in range(n):
		(start, end) = map(int, input().split())
		sub = a[start - 1:end]
		if a[start - 1] in a[:start - 1] or a[end - 1] in a[end:]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for _ in range(q):
		(l, r) = map(int, input().split())
		fa = False
		for i in range(l - 1):
			if s[i] == s[l - 1]:
				fa = True
		for i in range(r, n):
			if s[i] == s[r - 1]:
				fa = True
		if fa:
			print('YES')
		else:
			print('NO')


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	(n, q) = INL()
	S = INS()
	for _ in range(q):
		(l, r) = INL()
		P = S[l - 1:r]
		if S[l - 1] in S[:l - 1] or S[r - 1] in S[r:]:
			OPS('YES')
		else:
			OPS('NO')


import math
from collections import Counter, defaultdict, deque

def f(n, q, s, qr):
	ans = []
	for qi in qr:
		tp = s[qi[0] - 1:qi[1]]
		post = 0
		pos = 0
		flag = 0
		while pos < n and post < len(tp):
			if s[pos] == tp[post]:
				pos += 1
				post += 1
				if post == len(tp) - 1 and (not flag):
					pos += 1
			else:
				pos += 1
				if post != 0:
					flag = 1
		if post == len(tp):
			ans.append('YES')
		else:
			ans.append('NO')
	return ans
t = int(input())
result = []
for i in range(t):
	(n, q) = list(map(int, input().split()))
	s = input().strip()
	qr = []
	for i in range(q):
		qr.append(list(map(int, input().split())))
	result.append(f(n, q, s, qr))
for i in range(t):
	for j in range(len(result[i])):
		print(result[i][j])


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for _ in range(q):
		(l, r) = map(int, input().split())
		l = l - 1
		r = r - 1
		a = s[l:r + 1]
		b = s[l:r]
		i = r + 1
		flag = 0
		while i < n:
			if a == b + s[i]:
				flag = 1
				break
			i += 1
		if flag == 0:
			i = 0
			b = s[l + 1:r + 1]
			while i < l:
				if a == s[i] + b:
					flag = 1
					break
				i += 1
			if flag == 1:
				print('YES')
			else:
				print('NO')
		else:
			print('YES')


from collections import Counter
from collections import OrderedDict
from collections import defaultdict
import bisect
import math
from sys import setrecursionlimit

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def fre_count(mylist):
	return Counter(mylist)
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	arr = [int(x) for x in input()]
	fre = dict()
	for i in range(n):
		if arr[i] in fre:
			fre[arr[i]].append(i)
		else:
			fre[arr[i]] = []
			fre[arr[i]].append(i)
	for _ in range(q):
		(l, r) = map(int, input().split())
		c = 0
		try:
			if fre[arr[l - 1]][0] < l - 1:
				c += 1
		except:
			pass
		try:
			if fre[arr[r - 1]][-1] > r - 1:
				c += 1
		except:
			pass
		if c > 0:
			print('YES')
		else:
			print('NO')


for t in range(int(input())):
	(n, q) = [int(item) for item in input().split()]
	a = input()
	for (i, j) in [[int(item) for item in input().split()] for i in range(q)]:
		print('YES' if a[i - 1] in a[0:i - 1] or a[j - 1] in a[j:] else 'NO')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for k in range(q):
		(l, r) = map(int, input().split())
		s1 = s[l - 1:r]
		if s[:l - 1].find(s[l - 1]) != -1 or s[r:].find(s[r - 1]) != -1:
			print('YES')
		else:
			print('NO')


def main():
	for _ in range(int(input())):
		(n, q) = list(map(int, input().split()))
		s = input()
		qu = [list(map(int, input().split())) for i in range(q)]
		(f1, l1, f0, l0) = (s.find('1'), s.rfind('1'), s.find('0'), s.rfind('0'))
		for (l, r) in qu:
			if s[l - 1] == '0' and f0 < l - 1 or (s[l - 1] == '1' and f1 < l - 1) or (s[r - 1] == '0' and r - 1 < l0) or (s[r - 1] == '1' and r - 1 < l1):
				print('YES')
			else:
				print('NO')
main()


tc = int(input())
z = []
for i in range(tc):
	(n, m) = map(int, input().split())
	s = str(input())
	for j in range(m):
		(l, r) = map(int, input().split())
		a = False
		for k in range(l - 1):
			if s[k] == s[l - 1]:
				z.append('YES')
				a = True
				break
		if a == False:
			for k in range(n - r):
				if s[k + r] == s[r - 1]:
					z.append('YES')
					a = True
					break
		if a == False:
			z.append('NO')
for i in z:
	print(i)


for t in range(int(input())):
	(n, q) = list(map(int, input().split()))
	s = input()
	for i in range(q):
		(l, r) = list(map(int, input().split()))
		sprime = s[l - 1:r]
		if sprime[0] in s[:l - 1] or sprime[-1] in s[r:]:
			print('YES')
		else:
			print('NO')


def count(string):
	dict_a = {'0': [], '1': []}
	for i in range(len(string)):
		if string[i] == '0':
			dict_a['0'].append(i)
		else:
			dict_a['1'].append(i)
	return dict_a

def goodSubSeq(string, dict_a, s1, s2):
	char_1 = string[s1]
	char_2 = string[s2]
	if dict_a[char_1][0] != s1 or dict_a[char_2][-1] != s2:
		return True
	else:
		return False
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	string = input()
	dict_a = count(string)
	for l in range(q):
		(s1, s2) = map(int, input().split())
		s1 -= 1
		s2 -= 1
		if goodSubSeq(string, dict_a, s1, s2):
			print('YES')
		else:
			print('NO')


t = int(input())

def process(s, i, j):
	a = 0
	b = len(s) - 1
	while a < i - 1:
		if s[a] == s[i - 1]:
			return True
		a += 1
	while b > j - 1:
		if s[b] == s[j - 1]:
			return True
		b -= 1
	return False
for i in range(t):
	(n, q) = input().split(' ')
	n = int(n)
	q = int(q)
	s = input()
	for query in range(q):
		(a, b) = input().split(' ')
		if process(s, int(a), int(b)):
			print('YES')
		else:
			print('NO')


t = int(input())
ans = []
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input()
	pr = [s.find('1'), s.rfind('1'), s.find('0'), s.rfind('0')]
	for __ in range(q):
		(l, r) = map(int, input().split())
		l -= 1
		r -= 1
		k = 0
		if s[l] == '1':
			if pr[0] != -1 and pr[0] < l:
				k = 1
		elif s[l] == '0':
			if pr[2] != -1 and pr[2] < l:
				k = 1
		if s[r] == '1':
			if pr[1] != -1 and pr[1] > r:
				k = 1
		elif s[r] == '0':
			if pr[3] != -1 and pr[3] > r:
				k = 1
		if k == 1:
			ans.append('YES')
		else:
			ans.append('NO')
for i in ans:
	print(i)


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	s = input()
	for i in range(q):
		(start, end) = map(int, input().split())
		f = 0
		for x in range(start - 1):
			if s[x] == s[start - 1]:
				f = 1
				break
		if f:
			print('YES')
			continue
		for y in range(end, n):
			if s[end - 1] == s[y]:
				f = 1
				break
		if f:
			print('YES')
			continue
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, q) = input().split()
	qen = input()
	for k in range(int(q)):
		(start, end) = input().split()
		sub = qen[int(start) - 1:int(end)]
		s = sub[0]
		e = sub[-1]
		n_s = -1
		n_e = -1
		for i in range(len(qen)):
			if s == qen[i]:
				n_s = i
				break
		for j in range(len(qen) - 1, -1, -1):
			if e == qen[j]:
				n_e = j
				break
		if n_e - n_s + 1 > len(sub):
			print('YES')
		else:
			print('NO')


from sys import *
from queue import *
from collections import *
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	(n, q) = get_int()
	s = str(input())
	l1 = len(s)
	for _ in range(q):
		(l, r) = get_int()
		(l, r) = (l - 1, r - 1)
		if s[l] in s[:l] or s[r] in s[r + 1:]:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	s = input()
	qli = []
	for i in range(q):
		w = list(map(int, input().split()))
		qli.append(w)
	fir0 = -1
	fir1 = -1
	las0 = -1
	las1 = -0
	for i in range(n):
		if s[i] == '0':
			fir0 = i + 1
			break
	for i in range(n):
		if s[i] == '1':
			fir1 = i + 1
			break
	for i in range(n - 1, -1, -1):
		if s[i] == '0':
			las0 = i + 1
			break
	for i in range(n - 1, -1, -1):
		if s[i] == '1':
			las1 = i + 1
			break
	for i in range(q):
		flag = 0
		f = qli[i][0]
		l = qli[i][1]
		if s[f - 1] == '0' and s[l - 1] == '1':
			if f == fir0 and l == las1:
				flag = 1
		elif s[f - 1] == '1' and s[l - 1] == '0':
			if f == fir1 and l == las0:
				flag = 1
		elif s[f - 1] == '1' and s[l - 1] == '1':
			if f == fir1 and l == las1:
				flag = 1
		elif f == fir0 and l == las0:
			flag = 1
		if flag == 1:
			print('NO')
		else:
			print('YES')