You are given an array A containing N integers. Find if it is possible to choose exactly M elements from the array such that the MEX of the chosen elements is exactly K.

Recall that the *MEX* of an array is the smallest non-negative integer that does not belong to the array. For example, the *MEX* of [2, 2, 1] is 0 because 0 does not belong to the array, the *MEX* of [3, 1, 0, 1] is 2 because 0 and 1 belong to the array, but 2 does not.

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

- The first line contains an integer T, denoting the number of test cases. The T test cases then follow:
- The first line of each test case contains an integer N, M, K, denoting the length of the array, the number of elements to be chosen, and the required MEX respectively.
- The second line of each test case contains N space-separated integers A_{1},A_{2},\ldots,A_{N}, denoting the elements of the array.

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

For each test case, print YES if it is possible to choose M elements from the array A so that the MEX of the chosen elements is exactly K and NO otherwise. 

You may print each character of the string in uppercase or lowercase (for example, the strings yEs, yes, Yes and YES will all be treated as identical).

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

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$1 ≤ M ≤ N$
$0 ≤ A_{i}, K ≤ N$

----- Sample Input 1 ------ 
6
5 4 2
0 1 3 0 3
2 1 2
0 1
3 3 3
0 1 2
4 3 3
2 0 4 3
5 4 2
0 2 1 2 5
6 5 2
0 1 0 2 0 3

----- Sample Output 1 ------ 
YES
NO
YES
NO
NO
YES

----- explanation 1 ------ 
Test case $1$: The chosen elements are $0, 1, 3, 0$ and $MEX([0, 1, 3, 0]) = 2$.

Test case $3$: The chosen elements are $0, 1, 2$ and $MEX([0, 1, 2]) = 3$.

Test case $6$: The chosen elements are $0, 1, 0, 0, 3$ and $MEX([0, 1, 0, 0, 3]) = 2$.

Test case $2, 4, 5$: There is no way to choose elements to obtain the required MEX.

Difficulty: MEDIUM

Solutions:
from collections import Counter
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = Counter(a)
	s_count = 0
	for x in b:
		if x < k:
			s_count += 1
	if s_count < k or k > m or m > n - b.get(k, 0):
		print('NO')
	else:
		print('YES')


from array import array
from bisect import bisect
trials = int(input())
for i in range(trials):
	(_, to_choose, MEX) = [int(x) for x in input().split()]
	nums = sorted((int(x) for x in input().split() if int(x) != MEX))
	if to_choose < MEX:
		print('NO')
		continue
	nums = array('B', nums)
	counts = []
	for i in range(MEX):
		if len(nums) == 0 or nums[0] != i:
			print('NO')
			break
		index = bisect(nums, i)
		counts.append(index)
		nums = nums[index:]
	else:
		counts.append(len(nums))
		if sum(counts) >= to_choose:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(length, num_of_elements, mex) = [int(s) for s in str(input()).split()]
	elements = [int(s) for s in str(input()).split()]
	is_subset = set([x for x in range(mex)]).issubset(set(elements))
	filtered = [i for i in elements if i != mex]
	if is_subset and len(filtered) >= num_of_elements and (num_of_elements >= mex):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if n - l.count(k) < m or k > m:
		print('NO')
	else:
		f = 1
		for i in range(k):
			if i not in l:
				f = 0
				break
		if f:
			print('YES')
		else:
			print('NO')


def solve():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	f = True
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	for i in range(k):
		if i not in d:
			f = False
			break
	if k in d:
		n -= d[k]
	print('YES' if f and m >= k and (n >= m) else 'NO')
for _ in range(int(input())):
	solve()


t = input()
for c in range(0, int(t)):
	s = 0
	flag = 0
	last = -1
	mex = -1
	(n, m, k) = map(int, input().split())
	a = []
	b = []
	f = {}
	a = [int(i) for i in input().split()]
	a.sort()
	while k in a:
		a.remove(k)
	for i in range(len(a)):
		if a[i] > last + 1:
			mex = last + 1
		else:
			last = a[i]
			mex = last + 1
	if mex != k:
		print('NO')
	elif m >= k and m <= len(a):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	while K in A:
		A.remove(K)
	A.sort()
	last = -1
	MEX = -1
	for i in range(len(A)):
		if A[i] - last > 1:
			MEX = last + 1
			break
		else:
			last = A[i]
			MEX = last + 1
	if MEX != K:
		print('NO')
	elif M >= K and M <= len(A):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	p = list(map(int, input().split()))
	ck = p.count(k)
	ff = 0
	if ck > n - m:
		print('NO')
		continue
	if m < k:
		print('NO')
		continue
	for j in range(k):
		if j not in p:
			ff = 1
			break
	if ff == 0:
		print('YES')
	else:
		print('NO')


def remove_items(test_list, item):
	res = [i for i in test_list if i != item]
	return res
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	lst = remove_items(arr, k)
	if len(lst) < m:
		print('NO')
	else:
		flag = True
		for i in range(m + 1):
			if i not in lst:
				if i == k:
					print('YES')
					flag = False
					break
				else:
					print('NO')
					flag = False
					break
		if flag and i == k:
			print('YES')
		elif flag:
			print('NO')


def k_mex(a, n, m, k):
	if m >= k:
		for p in range(k):
			if p not in a:
				return False
		cur_n = n - k
		if k in a:
			if cur_n - a.count(k) < m - k:
				return False
		return True
	else:
		return False
for t in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	print('YES' if k_mex(a, n, m, k) == True else 'NO')


T = int(input())
for x in range(T):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	u_n = set(a)
	an = 'YES'
	o = n - a.count(k)
	if m <= o and m >= k:
		for i in range(k):
			if i not in u_n:
				an = 'NO'
				break
	else:
		an = 'NO'
	print(an)


tests = int(input(''))
for i in range(tests):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	unique_nums = set(arr)
	ans = 'YES'
	others = n - arr.count(k)
	if m <= others and m >= k:
		for j in range(k):
			if j not in unique_nums:
				ans = 'NO'
				break
	else:
		ans = 'NO'
	print(ans)


from sys import stdin, stdout

def pr(i):
	stdout.write(f'{i}\n')

def inp():
	return stdin.readline().strip()

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

def main():
	T = int(inp())
	for _ in range(T):
		(N, M, K) = na()
		A = list(na())
		A.sort()
		can = True
		if M < K:
			can = False
		i = 0
		while M:
			if i < K:
				try:
					A.remove(i)
				except ValueError:
					can = False
					break
				i += 1
				M -= 1
			elif i >= K:
				break
		if can and M > 0:
			while M:
				if len(A) == 0:
					can = False
					break
				if A[0] != K:
					A.remove(A[0])
				elif A[-1] != K:
					A.remove(A[-1])
				else:
					can = False
					break
				M -= 1
		if can:
			print('YES')
		else:
			print('NO')
main()


from math import ceil
try:
	n = int(input())
	for j in range(n):
		(a, b, c) = map(int, input().split())
		flag = True
		l = list(map(int, input().split()))
		for i in range(c):
			if i not in l:
				flag = False
				break
		if l.count(c) > a - b or c > b:
			flag = False
		print('YES' if flag else 'NO')
except:
	pass


for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l = []
	if m < k:
		print('NO')
	else:
		for i in l1:
			if i != k:
				l.append(i)
		l.sort()
		c = len(l)
		for i in range(k):
			if i not in l:
				print('NO')
				break
		else:
			if c >= m:
				print('YES')
			else:
				print('NO')


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	vals = list(map(int, input().split()))
	if m < k:
		print('NO')
	else:
		hset = set()
		count = 0
		for val in vals:
			if val == k:
				count += 1
			hset.add(val)
		rl = n - count
		if rl < m:
			print('NO')
		else:
			valid = True
			for i in range(k):
				if i not in hset:
					valid = False
					break
			if valid:
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	(N, M, K) = [int(s) for s in input().split()]
	A = [int(s) for s in input().split()]
	if M < K:
		print('NO')
	elif any((i not in A for i in range(K))):
		print('NO')
	elif N - A.count(K) < M:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	ans = 'YES'
	if k > m:
		ans = 'NO'
	else:
		for j in range(k):
			if a.count(j) <= 0:
				ans = 'NO'
				break
	if ans == 'NO':
		print('NO')
	elif n - a.count(k) >= m:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	d = set(arr)
	for i in range(k):
		if i in d and m > 0:
			m -= 1
			n -= 1
		else:
			print('NO')
			break
	else:
		if m == 0 or n - arr.count(k) >= m:
			print('YES')
		else:
			print('NO')


def ans(arr, m, n):
	if n == 0:
		if len(arr) - arr.count(0) >= m:
			return 'YES'
		else:
			return 'NO'
	else:
		hm = {}
		for y in arr:
			if y < n:
				if y in hm.keys():
					hm[y] += 1
				else:
					hm[y] = 1
		for i in range(0, n):
			if i in hm.keys():
				pass
			else:
				return 'NO'
		if m < len(hm):
			return 'NO'
		elif sum(hm.values()) >= m:
			return 'YES'
		elif len(arr) - arr.count(n) >= m:
			return 'YES'
		else:
			return 'NO'
test_cases = int(input())
while test_cases != 0:
	d = list(map(int, input().split()))
	d2 = list(map(int, input().split()))
	print(ans(d2, d[1], d[2]))
	test_cases -= 1


from collections import Counter

def mex(ans, k):
	m = Counter(ans)
	for i in range(k + 1):
		if i not in m.keys():
			return i
	else:
		return -1
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	(ans, len_) = ([], 0)
	for i in range(n):
		if l[i] != k:
			ans.append(l[i])
			len_ += 1
	if m < k:
		print('NO')
		continue
	if mex(ans, k) == k:
		if len_ >= m:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	cnt = 0
	cnt1 = 0
	x = 0
	for i in range(k):
		if i in arr:
			cnt = cnt + 1
	for i in range(n):
		if arr[i] == k:
			cnt1 = cnt1 + 1
	if m - k < 0:
		print('NO')
	elif cnt == k:
		if n - cnt - cnt1 >= m - k:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


test_cases = int(input())
for t in range(test_cases):
	(n, m, k) = (int(x) for x in input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	freq = [0 for i in range(n + 1)]
	for i in arr:
		freq[i] += 1
	if n - m < freq[k]:
		print('NO')
		continue
	if m < k:
		print('NO')
		continue
	for i in range(k):
		if freq[i] == 0:
			print('NO')
			break
	else:
		print('YES')


T = int(input())
for t in range(T):
	(N, M, K) = [int(x) for x in input().split(' ')]
	l1 = [int(x) for x in input().split(' ')]
	flag = 1
	if N - l1.count(K) < M or M < K:
		flag = 0
	else:
		for i in range(K):
			if i not in l1:
				flag = 0
				break
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	d = list(map(int, input().split()))
	n = d[0]
	m = d[1]
	k = d[2]
	l = list(map(int, input().split()))
	l.sort()
	uniq = n - l.count(k)
	s = []
	i = 0
	while i < n and l[i] < k:
		if l[i] not in s:
			s.append(l[i])
		i += 1
	large = uniq - i
	if len(s) == k and len(s) <= m:
		if len(s) == m:
			print('YES')
		elif len(s) <= m and m - i <= large:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def U(A, k):
	y = 0
	for i in A:
		if i != k:
			y += 1
	return y

def T(A):
	x = 0
	while True:
		if A.count(x) == 0:
			return x
			break
		else:
			x += 1
a = int(input())
for i in range(a):
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	if K == 0:
		if U(A, K) >= M:
			print('YES')
		else:
			print('NO')
	else:
		x = 0
		for j in range(K):
			if A.count(j) == 0:
				x += 1
		if x >= 1:
			print('NO')
		elif x == 0 and U(A, K) >= M and (M >= K):
			print('YES')
		else:
			print('NO')


def solve(n, m, k, arr):
	if m < k:
		return 'NO'
	arr.sort()
	curr_mex = 0
	count = 0
	for i in range(n):
		if arr[i] == k:
			continue
		if arr[i] > k:
			break
		if arr[i] == curr_mex:
			curr_mex += 1
		count += 1
	if curr_mex != k:
		return 'NO'
	if count >= m:
		return 'YES'
	for i in range(n - 1, -1, -1):
		if arr[i] > k:
			count += 1
		else:
			break
	if count >= m:
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	(n, m, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	print(solve(n, m, k, arr))


def mex(n, m, k, arr):
	bucket = [0 for _ in range(n + 1)]
	for e in arr:
		bucket[e] += 1
	for e in range(k):
		if bucket[e] == 0:
			return 'NO'
	if m + bucket[k] > n or m < k:
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(mex(n, m, k, arr))


t = int(input())
for q in range(t):
	nmk = list(map(int, input().split()))
	n = nmk[0]
	m = nmk[1]
	k = nmk[2]
	arr = list(map(int, input().split()))
	l1 = []
	flag = 0
	if m >= k:
		for i in range(n):
			if arr[i] != k:
				l1.append(arr[i])
		for j in range(k):
			if j not in l1:
				flag = 1
		if len(l1) >= m and flag == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
for t in range(T):
	line = input()
	(N, M, K) = [int(x) for x in line.split()]
	line = input()
	numbers = [int(x) for x in line.split()]
	if M < K:
		print('NO')
		continue
	counts = {}
	for n in numbers:
		counts[n] = counts.get(n, 0) + 1
	mex = 0
	countsum = 0
	unique_numbers = sorted(counts)
	for n in unique_numbers:
		if n != mex:
			break
		mex += 1
	for n in counts:
		if n == K:
			continue
		countsum += counts[n]
	if mex >= K and countsum >= M:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = [0] * (n + 1)
	for i in l:
		l1[i] += 1
	c = 0
	flag = 0
	for i in range(k):
		c += l1[i]
		if l1[i] == 0:
			flag = 1
			break
	if c < m:
		for i in range(k + 1, n + 1):
			c += l1[i]
			if c >= m:
				break
	if flag == 0 and c >= m and (m >= k):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	if m < k:
		print('NO')
	else:
		while k in A:
			A.remove(k)
		if len(A) < m:
			print('NO')
		else:
			ans = True
			for i in range(k):
				if i not in A:
					ans = False
					break
			print('YES' if ans else 'NO')


t = int(input())
for tt in range(t):
	(n, m, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	if len(list1) - list1.count(k) < m:
		print('NO')
	else:
		min_set = {x for x in list1 if x < k}
		if len(min_set) == k and m >= k:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m, k) = list(map(int, input().split()))
	arr = []
	f = 0
	arr = [int(i) for i in input().split()]
	for i in range(k):
		if i not in arr:
			print('NO')
			f = 1
			break
	if f == 0:
		if n - arr.count(k) >= m and m >= k:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(size, need, k) = map(int, input().split())
	L = list(map(int, input().split()))
	flag = False
	if need < k:
		print('NO')
		continue
	while k in L:
		L.remove(k)
	for i in range(0, k):
		if i not in L:
			flag = True
			break
	if flag:
		print('NO')
	elif len(L) < need:
		print('NO')
	else:
		print('YES')


T = int(input())
for _ in range(T):
	(N, M, K) = map(int, input().split())
	arr = list(map(int, input().split()))
	freq = dict()
	freq[K] = 0
	for i in range(N):
		freq[arr[i]] = freq.get(arr[i], 0) + 1
	if N - freq[K] < M:
		print('NO')
	else:
		flag = True
		for i in range(K):
			if i not in freq:
				print('NO')
				flag = False
				break
		if flag and K > M:
			print('NO')
		elif flag and K <= M:
			print('YES')


T = int(input())
for i in range(T):
	(a, b, c) = map(int, input().split(' '))
	lis = list(map(int, input().split()))
	lis = sorted(lis)
	n = lis.count(c)
	l = []
	for o in range(c):
		l.append(o)
	count = 0
	no = 0
	for j in l:
		if j in lis:
			count += 1
		else:
			no += 1
	if a - n >= b and n != 0 and (min(lis) <= c <= max(lis)) or (min(lis) < c < max(lis) and n == 0):
		if count >= len(l) and count <= b:
			print('YES')
		else:
			print('NO')
	elif c > max(lis) and c - max(lis) == 1:
		if count - b <= 0 and no == 0:
			print('YES')
		else:
			print('NO')
	elif c < min(lis) and c == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	a = [0] * (n + 1)
	for i in l:
		a[i] += 1
	if n - a[k] < m:
		print('NO')
	else:
		mx = 0
		c = 0
		if k > m:
			print('NO')
			continue
		for i in range(k):
			if a[i] != 0:
				mx += 1
			else:
				break
		if mx == k:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k > m:
		print('NO')
	else:
		c = 0
		for i in range(k):
			if i not in l:
				c += 1
				break
		if c == 0:
			d = 0
			for i in l:
				if i == k:
					d += 1
			if n - d >= m:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


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


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	c = 0
	x = 0
	ar = [0] * (n + 1)
	for i in arr:
		ar[i] += 1
	for i in range(k):
		if ar[i] > 0:
			c += 1
		else:
			break
	if k <= m and c == k and (n - ar[k] >= m):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	count = 0
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	if M == 1:
		if K == 0:
			for item in A:
				if item != 0:
					print('YES')
					break
		elif K == 1 and A.count(0) > 0:
			print('YES')
		else:
			print('NO')
	elif M < K:
		print('NO')
	elif N - A.count(K) < M:
		print('NO')
	else:
		for i in range(K):
			if i in A:
				count += 1
		if count == K:
			print('YES')
		else:
			print('NO')


T = int(input())
for q in range(T):
	(N, M, K) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	counter = 0
	for i in range(N):
		if A[i] != K:
			counter += 1
	i = 0
	while i < K:
		if i not in A:
			break
		i += 1
	if M < K:
		print('NO')
	elif i != K:
		print('NO')
	elif counter < M:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = 'NO'
	a = sorted(set(arr))
	c = 0
	if k <= m:
		for i in range(len(a)):
			if a[i] >= k:
				break
			c = i + 1
		arr.sort()
		if c == k:
			count = 0
			for i in range(n):
				if arr[i] != k:
					count += 1
				if count == m:
					break
			if count == m:
				ans = 'YES'
	print(ans)


import io, os, sys

def solve():
	(n, m, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	lis.sort()
	mex = 0
	for index in range(n):
		if mex == lis[index]:
			mex += 1
	if mex < k or n - lis.count(k) < m or m < k:
		print('NO')
	else:
		print('YES')
T = int(input())
while T:
	solve()
	T -= 1


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	if m < k:
		print('NO')
	elif arr.count(k) > n - m:
		print('NO')
	else:
		ans = 'YES'
		for i in range(k):
			if i not in arr:
				ans = 'NO'
				break
		print(ans)


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	cLis = [0] * 101
	for i in lis:
		cLis[i] += 1
	c = n - lis.count(k)
	if c >= m:
		if m >= k:
			flag = True
			for i in range(k):
				if cLis[i] == 0:
					flag = False
					break
			print('YES' if flag else 'NO')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	run = False
	cg = 0
	cs = 0
	mn = 0
	dict = {}
	for i in arr:
		if i > k:
			cg += 1
		if i < k:
			try:
				dict[k - i] += 1
			except:
				dict[k - i] = 1
		if k == 0:
			run = True
		elif i == 0:
			run = True
	if len(dict.keys()) != k:
		run = False
	if run:
		if m < k:
			run = False
	if run:
		if sum(dict.values()) + cg < m:
			run = False
	if run:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [i for i in range(k)]
	ok = False
	y = list(set(a))
	y.sort()
	x = n - a.count(k)
	if y[:k] == l and m <= x and (m >= k):
		ok = True
	if ok:
		print('YES')
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = [int(i) for i in input().split()]
	if k > m:
		print('NO')
		continue
	d = dict(Counter(l))
	flag = 0
	for i in range(k):
		if i not in d:
			flag = 1
			break
	if flag == 1:
		print('NO')
	elif m <= n - l.count(k):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = map(int, input().split())
	f = [0] * (n + 1)
	for i in a:
		f[i] += 1
	mex = 0
	for i in range(k):
		if f[i] > 0:
			mex += 1
		else:
			break
	if m >= k and mex == k and (n - f[k] >= m):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ar = [0] * (n + 1)
	for i in range(n):
		ar[l[i]] += 1
	mex = 0
	for i in range(k):
		if ar[i] > 0:
			mex += 1
		else:
			break
	if k <= m and mex == k and (n - ar[k] >= m):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m, k) = map(int, input().split())
	num = list(map(int, input().split()))
	isThere = True
	another = [i for i in num if i != k]
	another.sort()
	if len(another) < m:
		Ans = 'NO'
	else:
		for i in range(k):
			if i not in another or k > m:
				isThere = False
				Ans = 'NO'
				break
		if isThere:
			Ans = 'YES'
	print(Ans)