You have an array $a_1, a_2, \dots, a_n$. All $a_i$ are positive integers.

In one step you can choose three distinct indices $i$, $j$, and $k$ ($i \neq j$; $i \neq k$; $j \neq k$) and assign the sum of $a_j$ and $a_k$ to $a_i$, i. e. make $a_i = a_j + a_k$.

Can you make all $a_i$ lower or equal to $d$ using the operation above any number of times (possibly, zero)?


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 2000$) — the number of test cases.

The first line of each test case contains two integers $n$ and $d$ ($3 \le n \le 100$; $1 \le d \le 100$) — the number of elements in the array $a$ and the value $d$.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$) — the array $a$.


-----Output-----

For each test case, print YES, if it's possible to make all elements $a_i$ less or equal than $d$ using the operation above. Otherwise, print NO.

You may print each letter in any case (for example, YES, Yes, yes, yEs will all be recognized as positive answer).


-----Examples-----

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


-----Note-----

In the first test case, we can prove that we can't make all $a_i \le 3$.

In the second test case, all $a_i$ are already less or equal than $d = 4$.

In the third test case, we can, for example, choose $i = 5$, $j = 1$, $k = 2$ and make $a_5 = a_1 + a_2 = 2 + 1 = 3$. Array $a$ will become $[2, 1, 5, 3, 3]$.

After that we can make $a_3 = a_5 + a_2 = 3 + 1 = 4$. Array will become $[2, 1, 4, 3, 3]$ and all elements are less or equal than $d = 4$.

Difficulty: EASY
Tags: Mathematics

Sorting

Implementation

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
t = int(input())
for i in range(t):
	(a, d) = map(int, input().split())
	s = input().split(' ')
	s = [int(x) for x in s]
	s.sort()
	if s[0] + s[1] <= d or s[-1] <= d:
		print('YES')
	else:
		print('NO')


import sys, math, itertools
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for t in [wtf[i:i + 2] for i in range(1, len(wtf), 2)]:
	(n, d) = map(int, t[0].split())
	A = sorted(list(map(int, t[1].split())))
	print('YES' if A[-1] <= d or A[0] + A[1] <= d else 'NO')


import sys
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input().rstrip())
	for i in range(tests):
		(k, d) = map(int, input().rstrip().split())
		arr_ = list(map(int, input().rstrip().split()))
		arr_.sort()
		max_ = arr_[-1]
		min_1 = arr_[0]
		min_2 = arr_[1]
		if max_ <= d or min_1 + min_2 <= d:
			output('YES')
		else:
			output('NO')
		output('\n')
main()


import sys
MOD = 1000000007
import math

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

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

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

def write_line(out):
	return sys.stdout.write(str(out) + '\n')

def solve():
	(n, d) = get_ints()
	arr = list(get_ints())
	arr.sort()
	if arr[-1] <= d:
		return 'YES'
	if arr[0] + arr[1] > d:
		return 'NO'
	else:
		return 'YES'
	return 0
t = int(input())
while t:
	write_line(solve())
	t -= 1


def fun(lst, d):
	flag = 1
	for el in lst:
		if el > d:
			flag = 0
	if flag == 1:
		return 'YES'
	for i in range(len(lst)):
		for j in range(i + 1, len(lst)):
			if lst[i] + lst[j] <= d:
				flag = 1
				break
	if flag == 1:
		return 'YES'
	else:
		return 'NO'
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	lst = [int(i) for i in input().split()]
	print(fun(lst, d))


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[n - 1] <= d:
		print('YES')
		continue
	elif a[0] + a[1] <= d:
		print('YES')
		continue
	else:
		print('NO')


def solve(a, n, d):
	if a[-1] <= d:
		return 'YES'
	s = a[0] + a[1]
	if s <= d:
		return 'YES'
	return 'NO'
t = int(input())
while t:
	t -= 1
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	print(solve(a, n, d))


ans = []
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	arr = sorted(map(int, input().split()))
	if arr[-1] <= d or sum(arr[:2]) <= d:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst.sort()
	if lst[-1] <= b:
		print('YES')
	elif lst[0] + lst[1] <= b:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = sorted(map(int, input().split()))
	print('YES' if a[-1] <= d or a[0] + a[1] <= d else 'NO')


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


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	if all((i <= x for i in arr)):
		print('YES')
		continue
	elif arr[0] + arr[1] <= x:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, d) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	if max(a) <= d:
		print('YES')
		continue
	m1 = 200
	m2 = 200
	for i in a:
		if i < m1:
			m2 = m1
			m1 = i
		elif i < m2:
			m2 = i
	if m1 + m2 <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	mi = None
	mii = None
	for i in range(2):
		for j in range(1, n - i):
			if l[j - 1] < l[j]:
				(l[j - 1], l[j]) = (l[j], l[j - 1])
	ma = max(l)
	if ma <= d:
		print('YES')
		continue
	if l[n - 1] <= d and l[n - 2] <= d and (l[n - 1] + l[n - 2] <= d):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	if l[n - 1] <= d:
		print('YES')
	elif l[0] + l[1] <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	flag = True
	l.sort()
	s = l[0] + l[1]
	for i in l:
		if i > d:
			flag = False
			break
	if flag == True or s <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
for kk in range(t):
	(n, d) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort()
	k = 0
	for i in a:
		if i <= d:
			k += 1
	if k == n or a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, d) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	c = 0
	k = 0
	z = 0
	for i in range(len(l)):
		if l[i] <= d:
			c += 1
	if c == len(l):
		k = 1
		print('YES')
	if k == 0:
		for i in range(len(l) - 1):
			for j in range(i + 1, len(l)):
				if l[i] + l[j] <= d:
					print('YES')
					z = 1
					break
			if z == 1:
				break
		else:
			print('NO')


t = int(input(''))
for k in range(t):
	s1 = input('')
	l1 = s1.split(' ')
	(n, d) = (int(l1[0]), int(l1[1]))
	s2 = input('')
	l = s2.split(' ')
	for i in range(n):
		l[i] = int(l[i])
	l.sort()
	all_flag = 0
	break_ind = 0
	for i in range(n):
		if l[i] > d:
			break_ind = i - 1
			all_flag = 1
	if all_flag == 0:
		print('YES')
	elif break_ind == -1:
		print('NO')
	else:
		brk = 0
		for i in range(break_ind + 1):
			num1 = l[i]
			for j in range(break_ind + 1):
				if i != j:
					num2 = l[j]
					if l[i] + l[j] <= d:
						print('YES')
						brk = 1
						break
			if brk == 1:
				break
		if brk == 0:
			print('NO')


t = int(input())
for _ in range(t):
	(n, d) = (int(i) for i in input().split())
	a = sorted((int(i) for i in input().split()))
	res = 'YES' if a[-1] <= d or sum(a[:2]) <= d else 'NO'
	print(res)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	if l[-1] > k:
		if l[0] + l[1] <= k:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, d) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	if a[n - 1] <= d or a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, d) = list(map(int, input().strip().split()))
	list1 = list(map(int, input().strip().split()))
	list1.sort()
	if list1[n - 1] <= d:
		print('YES')
	elif list1[0] + list1[1] <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	for i in l:
		if i <= d:
			ans += 1
	if l[0] + l[1] <= d:
		print('YES')
	elif ans == n:
		print('YES')
	else:
		print('NO')


def solve(a, d):
	a.sort()
	if a[0] + a[1] <= d:
		print('YES')
	elif a[-1] <= d:
		print('YES')
	else:
		print('NO')
for i in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	solve(a, d)


t = int(input())
for caso in range(t):
	(n, d) = list(map(int, input().split(' ')))
	nums = sorted(list(map(int, input().split(' '))))
	(c1, c2) = (nums[0], nums[1])
	cf = nums[-1]
	if c1 + c2 <= d or cf <= d:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	(n, d) = input().split()
	n = int(n)
	d = int(d)
	l = [int(j) for j in input().split()]
	l.sort()
	if max(l) <= d:
		print('YES')
	elif l[0] + l[1] <= d:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(_, d) = map(int, input().split())
	(*a,) = map(int, input().split())
	if max(a) <= d:
		print('YES')
	else:
		x = sorted(a)
		if x[0] + x[1] <= d:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if max(a) <= k or a[0] + a[1] <= k:
		print('yes')
	else:
		print('no')


t = int(input())
while t:
	t -= 1
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	b = max(a)
	if b > d:
		c = min(a)
		a.remove(c)
		if d - c < min(a):
			print('NO')
		else:
			print('YES')
	elif n >= 2:
		print('YES')
	else:
		print('NO')


def solve():
	(n, d) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	s = set([])
	for z in range(n):
		for z1 in range(z + 1, n):
			s.add(arr[z] + arr[z1])
	maxele = max(arr)
	minS = min(s)
	if maxele <= d:
		print('YES')
	elif minS <= d:
		print('YES')
	else:
		print('NO')
	return 0

def main():
	t = int(input())
	while t > 0:
		solve()
		t -= 1
	return 0
main()


for i in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	c = 0
	for i in a:
		if i > d:
			c = 1
			break
	if c == 0:
		print('YES')
	elif a[-1] + a[-2] > d:
		print('NO')
	else:
		print('YES')


c = int(input())
r = [False for i in range(c)]
for t in range(c):
	d = int(input().split()[1])
	ar = [int(i) for i in input().split()]
	r[t] = True
	for i in ar:
		if i <= d:
			continue
		new1 = ar.copy()
		new1.remove(i)
		a = min(new1)
		new1.remove(min(new1))
		b = min(new1)
		if a + b > d:
			r[t] = False
			break
for i in r:
	if i:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(_, d) = map(int, input().split())
	z = sorted(map(int, input().split()))
	print('YES' if z[-1] <= d or sum(z[:2]) <= d else 'NO')


import sys, io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = 1
	for i in a:
		if i > d:
			flag = 0
			break
	if flag:
		print('YES')
		continue
	a.sort()
	if a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for x in range(0, t):
		line = input().split(' ')
		n = int(line[0])
		d = int(line[1])
		arr = list(map(int, input().split(' ')))
		arr.sort()
		if arr[n - 1] <= d:
			print('YES')
		elif arr[0] > d or arr[1] > d:
			print('NO')
		elif arr[0] + arr[1] > d:
			print('NO')
		else:
			print('YES')
main()


import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	d = int(l[1])
	l = input().split()
	li = [int(i) for i in l]
	li.sort()
	a = li[0]
	b = li[1]
	for i in range(n):
		li[i] = min(li[i], a + b)
	z = max(li)
	if z <= d:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	if l[-1] <= d or l[0] + l[1] <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	length = len(arr)
	if arr[length - 1] <= d or arr[0] + arr[1] <= d:
		print('YES')
	else:
		print('NO')


a = int(input())
l = []
for i in range(0, a):
	m = []
	for j in range(2):
		n = input().split(' ')
		for i in range(len(n)):
			n[i] = int(n[i])
		m.append(n)
	l.append(m)
for i in range(len(l)):
	n = l[i][0][0]
	d = l[i][0][1]
	y = 0
	x = 0
	k = d
	t = d
	for j in range(n):
		c = l[i][1][j]
		if c <= d // 2:
			x += 1
			y += 1
			t = c
			if y == 2:
				break
		elif c <= d:
			x += 1
			k = min(c, k)
	if y == 2:
		print('YES')
	elif k + t <= d:
		print('YES')
	elif x == n:
		print('YES')
	else:
		print('NO')


answers = []
t = int(input())
for i in range(t):
	(n, d) = map(int, input().split())
	arr = []
	arr.append(input().split())
	arr2 = []
	for i in range(len(arr[0])):
		arr2.append(int(arr[0][i]))
	pr_index = []
	for i in range(n):
		if arr2[i] <= d:
			pr_index.append(i)
	arr2.sort()
	if len(arr2) == 1 and arr2[0] <= d:
		answers.append('YES')
	elif len(arr2) == 1 and arr2[0] >= d:
		answers.append('NO')
	elif len(arr2) > 1:
		if len(pr_index) == n or arr2[0] + arr2[1] <= d:
			answers.append('YES')
		else:
			answers.append('NO')
for i in answers:
	print(i)


t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	c1 = 0
	for i in range(n - 1, 0, -1):
		c1 += i
	c = 0
	for i in range(n - 1):
		for j in range(i + 1, n):
			if l[i] + l[j] > d:
				c += 1
	c2 = 0
	for i in range(n):
		if l[i] <= d:
			c2 += 1
	if c2 == n:
		print('YES')
	elif c == c1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	(n, d) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	flag = True
	for i in a:
		if i > d:
			flag = False
			break
	a.sort()
	sum = a[0] + a[1]
	if flag == True or sum <= d:
		print('YES')
	else:
		print('NO')
	t -= 1


def isReplaced(l, d, n):
	l1 = sorted(l)
	if l1[0] + l1[1] <= d or l1[n - 1] <= d:
		return 'YES'
	return 'NO'
for i in range(int(input())):
	(n, d) = map(int, input().split())
	l = map(int, input().split())
	print(isReplaced(l, d, n))


def solve():
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	if not a or not d or (not n) or (d == 0):
		return 'NO'
	if max(a) <= d:
		return 'YES'
	a.sort()
	if a[0] + a[1] > d:
		return 'NO'
	k = a[0]
	j = a[1]
	while min(a) < d:
		for i in range(2, len(a)):
			a[i] = k + j
		if max(a) <= d:
			break
		a.sort()
		k = a[0]
		j = a[1]
	if max(a) <= d:
		return 'YES'
	else:
		return 'NO'

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


t = int(input())
for ttt in range(t):
	(n, d) = [int(i) for i in input().split(' ')]
	aas = [int(i) for i in input().split(' ')]
	aas.sort()
	if sum((i <= d for i in aas)) == n:
		print('YES')
	elif aas[0] + aas[1] <= d:
		print('YES')
	else:
		print('NO')


def panda(n, k, l):
	l.sort()
	if l[-1] <= k:
		return 'YES'
	if l[0] + l[1] <= k:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	print(panda(n, k, l))


n = int(input())
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	l.sort()
	if l[-1] > b:
		if l[0] + l[1] <= b:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	if arr[0] + arr[1] <= d:
		print('YES')
	elif arr[-1] <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
for tt in range(t):
	(n, d) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	if a[len(a) - 1] <= d:
		print('YES')
	elif a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


import sys

def replacingElements(n, d, a):
	a.sort()
	if a[-1] <= d or a[0] + a[1] <= d:
		return 'YES'
	return 'NO'

def main():
	for _ in range(int(input())):
		(n, d) = map(int, input().split())
		a = [int(i) for i in input().split()]
		print(replacingElements(n, d, a))
main()


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

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())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	for i in a:
		if i > m:
			c += 1
	if c == 0:
		print('YES')
	elif a[0] + a[1] <= m:
		print('YES')
	else:
		print('NO')


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.buffer.readline())
Neo = lambda : list(map(int, sys.stdin.buffer.readline().split()))
for _ in range(I()):
	(n, d) = Neo()
	A = Neo()
	A.sort()
	if A[-1] <= d or A[0] + A[1] <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	a.sort(reverse=True)
	flag = 0
	for i in a:
		if i > d:
			flag = 1
			break
	if flag:
		if a[-1] + a[-2] > d:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


t = int(input())
ans = []
for i in range(t):
	(n, d) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	a = list(reversed(sorted(a)))
	can = True
	while a[0] > d:
		if a[len(a) - 1] + a[len(a) - 2] <= d:
			a[0] = a[len(a) - 1] + a[len(a) - 2]
		else:
			can = False
			break
		a = list(reversed(sorted(a)))
	if can:
		ans.append('yes')
	else:
		ans.append('no')
for i in ans:
	print(i)


t = int(input())
for j in range(0, t):
	l1 = [int(x) for x in input().split()]
	n = l1[0]
	d = l1[1]
	l2 = [int(x) for x in input().split()]
	l2.sort()
	if l2[n - 1] <= d:
		print('YES')
	elif l2[0] + l2[1] <= d:
		print('YES')
	else:
		print('NO')


def solver():
	tc = int(input())
	for i in range(tc):
		(n, d) = [int(i) for i in input().split()]
		a = [int(i) for i in input().split()]
		a.sort()
		if max(a) <= d:
			print('YES')
		elif a[0] + a[1] <= d:
			print('YES')
		else:
			print('NO')
	return
solver()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	A = sorted(map(int, input().split()))
	print('Yes' if A[-1] <= d or A[0] + A[1] <= d else 'No')


import sys
input = sys.stdin.readline

def solve():
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	v = arr[0] + arr[1]
	return 'YES' if min(arr[-1], v) <= d else 'NO'
for _ in range(int(input())):
	print(solve())


import functools
from sys import stdin
from collections import defaultdict, Counter
from math import ceil

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

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

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	(n, d) = minput()
	a = linput()
	a.sort()
	if a[-1] <= d or a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	ND = list(map(int, input().strip().split()))
	N = ND[0]
	D = ND[1]
	a = list(map(int, input().strip().split()))
	a.sort()
	if a[0] + a[1] <= D or a[N - 1] <= D:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = input().split()
	n = int(n)
	d = int(d)
	a = [int(x) for x in input().split()]
	a.sort()
	if a[n - 1] <= d:
		print('YES')
	elif n == 1:
		print('NO')
	elif a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	s = input().split()
	(n, d) = (int(s[0]), int(s[1]))
	s = input().split()
	A = [int(s[i]) for i in range(n)]
	ms = 999999
	bigger = False
	for i in range(n - 1):
		if A[i] > d:
			bigger = True
		for j in range(i + 1, n):
			if ms > A[i] + A[j]:
				ms = A[i] + A[j]
	if A[-1] > d:
		bigger = True
	if bigger:
		if ms <= d:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(l, reverse=False)
	if l[0] + l[1] > d and l[-1] > d:
		print('NO')
	else:
		print('YES')


t = int(input())
for t in range(0, t):
	q = list(map(int, input().rstrip().split()))
	n = q[0]
	d = q[1]
	a = list(map(int, input().rstrip().split()))
	a.sort()
	if a[n - 1] <= d:
		print('YES')
	elif a[0] + a[1] > d:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, d) = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	arr.sort()
	flag = True
	if arr[0] + arr[1] > d and arr[-1] > d:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[len(a) - 1] <= k:
		print('YES')
	elif a[0] + a[1] <= k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(l)
	if l[n - 1] <= d:
		print('YES')
	elif l[0] + l[1] <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	array = list(map(int, input().split()))
	array.sort()
	sum = 0
	flag = 0
	for i in range(0, n):
		if array[i] > k:
			flag = 1
	if flag == 0 or array[0] + array[1] <= k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	if a[-1] <= k:
		print('YES')
	elif a[0] + a[1] <= k:
		print('YES')
	else:
		print('NO')


import sys
import os
import math
import copy
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations, accumulate

def Int():
	return int(sys.stdin.readline())

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

def Lstr():
	return list(sys.stdin.readline().strip())

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

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

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def watch(x):
	return print(x)

def common(l1, l2):
	return set(l1).intersection(l2)

def Most_frequent(list):
	return max(set(list), key=list.count)

def solution():
	for _ in range(Int()):
		(n, m) = Mint()
		a = List()
		ok = True
		for i in range(n):
			if a[i] > m:
				ok = False
		a.sort()
		if a[0] + a[1] <= m or ok:
			print('YES')
		else:
			print('NO')
solution()


n = int(input())
for i in range(n):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if max(a) <= d or a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[1] + a[0] <= m or a[-1] <= m:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	(b, c) = map(int, input().split())
	d = list(map(int, input().split(' ')))
	d.sort()
	if d[-1] <= c or d[0] + d[1] <= c:
		print('YES')
	else:
		print('NO')


o = int(input())
for i in range(o):
	w = input().split()
	n = int(w[0])
	d = int(w[1])
	b = list(map(int, input().strip().split()))[:n]
	b.sort()
	if d == b[n - 1] or d > b[n - 1]:
		print('YES')
		continue
	elif d >= b[0] + b[1]:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if max(a) <= x:
		print('YES')
	else:
		c = min(a)
		a.remove(min(a))
		b = min(a)
		if c + b <= x:
			print('YES')
		else:
			print('NO')
	t = t - 1


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
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 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, d) = map(int, input().split())
		a = list(map(int, input().split()))
		a.sort()
		if a[0] + a[1] <= d and a[0] <= d and (a[1] <= d):
			print('YES')
		else:
			f = 0
			for i in a:
				if i > d:
					f = 1
			if f:
				print('NO')
			else:
				print('YES')
	return
main()


import math
import sys
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
input = sys.stdin.readline
readint = lambda : int(input())
readintm = lambda : map(int, input().strip().split())
readintl = lambda : list(map(int, input().strip().split()))
readfloatm = lambda : map(float, input().strip().split())
readfloatl = lambda : list(map(float, input().strip().split()))
readstr = lambda : input().strip()
readstrl = lambda : list(input().strip())
join = lambda x, l: x.join(map(str, l))
print = lambda *x: sys.stdout.write(' '.join(map(str, x)) + '\n')
printl = lambda l: sys.stdout.write(' '.join(map(str, l)) + '\n')
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
mod = 1000000007
for _ in range(readint()):
	(n, d) = readintm()
	a = sorted(readintl())
	if a[-1] <= d or a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, s) = list(map(int, input().split()))
		arr = list(map(int, input().split()))
		arr.sort()
		if n == 1:
			if arr[0] > s:
				yield 'NO'
			else:
				yield 'YES'
		elif sum([arr[0], arr[1]]) > s and arr[-1] > s:
			yield 'NO'
		else:
			yield 'YES'
t = int(input())
ans = gift()
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	f = 1
	for i in range(n):
		if arr[i] > d:
			f = 0
			break
	if f == 1:
		print('YES')
		continue
	else:
		f = 0
		for i in range(n):
			if arr[i] < d:
				for j in range(n):
					if arr[i] + arr[j] <= d and i != j:
						f = 1
						break
				if f == 1:
					break
		if f == 1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = True
	for i in range(n):
		if a[i] > d:
			flag = False
	if flag == True:
		print('YES')
		continue
	a.sort()
	immature = a[0] + a[1]
	if immature <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	r = a[0] + a[1]
	if max(a) > d:
		if r <= d:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


R = lambda : map(int, input().split())
(t,) = R()
exec(t * "n,d=R();x,y,*_,z=sorted(R());print('YNEOS'[x+y>d<z::2]);")


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())
t = inp()
for i in range(t):
	(n, d) = list(invr())
	a = list(invr())
	answer = ''
	minst = float('inf')
	nestMin = float('inf')
	mak = -1
	for j in a:
		mak = max(j, mak)
		if j <= minst:
			nestMin = minst
			minst = j
		elif j < nestMin:
			nestMin = j
	solution = min(nestMin + minst, mak)
	if d >= solution:
		answer += 'yes'
	else:
		answer += 'no'
	print(answer)


t = int(input())
for p in range(t):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	if all((i <= d for i in a)):
		print('YES')
	else:
		for i in a:
			if i <= d:
				c += 1
			elif a[0] + a[1] > d:
				print('NO')
				break
			else:
				c += 1
		if c == n:
			print('YES')


from math import inf
from collections import *
import math, os, sys, heapq, bisect, random, threading
from functools import lru_cache, reduce
from itertools import *
import sys

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

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

def inpu():
	return int(inp())

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())
(M, M1) = (1000000007, 998244353)

def main():
	t = inpu()
	for i in range(t):
		(n, d) = sep()
		a = lis()
		a.sort()
		fl = True
		for i in a:
			if i > d:
				fl = False
				break
		if fl:
			print('YES')
		elif a[0] + a[1] <= d:
			print('YES')
		else:
			print('NO')
main()


T = int(input())
while T:
	T -= 1
	(n, d) = map(int, input().split())
	nums = [int(x) for x in input().split()]
	nums.sort()
	if nums[n - 1] <= d or nums[0] + nums[1] <= d:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, d) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	flag = 0
	for j in range(len(arr)):
		if arr[j] > d:
			flag = 1
			break
	m1 = min(arr)
	arr.remove(m1)
	m2 = min(arr)
	if flag == 0:
		print('YES')
	elif m1 + m2 <= d:
		print('YES')
	else:
		print('NO')


import sys
num_tests = int(sys.stdin.readline().rstrip())
for t in range(num_tests):
	(num_ints, d) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
	xs = sorted(list(map(int, sys.stdin.readline().rstrip().split(' '))))
	if xs[-1] <= d or xs[0] + xs[1] <= d:
		print('YES')
	else:
		print('NO')


import sys

def main():
	txt = str(sys.stdin.readline())
	(n, d) = list(map(int, txt.split(' ')))
	txt = str(sys.stdin.readline())
	lt = list(map(int, txt.split(' ')))
	if max(lt) <= d:
		return 0
	else:
		lt.sort()
		if lt[0] + lt[1] <= d:
			return 0
		else:
			return 1
t = int(input())
for i in range(t):
	ans = main()
	if ans == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, n) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list1.sort()
	k = list1[0] + list1[1]
	if list1[-1] <= n:
		print('YES')
	elif k <= n:
		print('YES')
	else:
		print('NO')


import sys
from collections import Counter

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

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

def solve(a, d):
	if a[len(a) - 1] <= d:
		print('YES')
		return
	print('YES' if a[0] + a[1] <= d else 'NO')

def main():
	t = int(input())
	for i in range(t):
		(n, d) = MI()
		a = sorted(LI())
		solve(a, d)
main()


t = int(input())
for _ in range(t):
	inp = input().split()
	a = int(inp[0])
	b = int(inp[1])
	lst = input().split()
	lst = [int(i) for i in lst]
	lst.sort()
	if lst[0] + lst[1] <= b or lst[-1] <= b:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, d) = map(int, input().split())
	lis = list(map(int, input().strip().split()))
	lis.sort()
	if lis[n - 1] <= d:
		print('YES')
	elif lis[0] + lis[1] <= d:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(N, D) = map(int, input().split())
	L = sorted(list(map(int, input().split())))
	if L[0] + L[1] <= D or max(L) <= D:
		print('YES')
	else:
		print('NO')


from collections import defaultdict, Counter
nt = int(input())
for test in range(nt):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[-1] <= d:
		print('YES')
	else:
		s = sum(a[0:2])
		if s > d:
			print('NO')
		else:
			print('YES')


t = int(input())
while t:
	(n, d) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	if a[-1] <= d:
		print('YES')
	elif a[0] + a[1] > d:
		print('NO')
	else:
		print('YES')
	t -= 1


t = int(input())
for i in range(t):
	in_str = input()
	(n, d) = list(map(int, in_str.split()))
	num_str = input()
	num = list(map(int, num_str.split()))
	minn = min(num)
	maxx = max(num)
	if maxx <= d:
		print('YES')
	else:
		num.remove(minn)
		minnn = min(num)
		num.remove(minnn)
		if minn + minnn <= d:
			print('YES')
		else:
			print('NO')


import sys

def get_ints():
	return map(int, I().split())

def get_list():
	return list(map(int, I().split()))

def I():
	return sys.stdin.readline()
for _ in range(int(I())):
	(n, d) = get_ints()
	L = get_list()
	L = sorted(L)
	if L[0] > d:
		print('NO')
	else:
		flag = True
		if L[0] + L[1] > d:
			flag = False
		flag2 = True
		for i in L:
			if i > d:
				flag2 = False
				break
		if flag or flag2:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	if max(a) <= d:
		print('YES')
	else:
		x = min(a)
		a.remove(x)
		y = min(a)
		if x + y <= d:
			print('YES')
		else:
			print('NO')


from heapq import nsmallest

def read_ints():
	return map(int, input().split())
(t_n,) = read_ints()
for i_t in range(t_n):
	(n, d) = read_ints()
	a_seq = tuple(read_ints())
	if sum(nsmallest(2, a_seq)) <= d or max(a_seq) <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	l = list(map(int, input().split()))
	temp = l.copy()
	temp.sort()
	f = 0
	ans = 'YES'
	for i in l:
		if i > d:
			f = 1
			ans = 'NO'
			break
	if f == 1:
		if temp[0] + temp[1] <= d:
			ans = 'YES'
	print(ans)


def solve():
	(n, d) = input().split()
	n = int(n)
	d = int(d)
	xd = input().split()
	xd1 = []
	for i in xd:
		xd1.append(int(i))
	xd1.sort()
	if int(xd1[-1]) <= d or int(xd1[0]) + int(xd1[1]) <= d:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	solve()


def rep_element(l, d):
	_l = l[:]
	_l.sort()
	(s1, s2) = (_l[0], _l[1])
	f = 0
	for i in l:
		if i > d and i in (s1, s2):
			f = 1
			break
		elif i > d and s1 + s2 > d:
			f = 1
			break
	if f == 1:
		return 'NO'
	else:
		return 'YES'
test_case = int(input())
ans = []
for i in range(test_case):
	(n, d) = map(int, input().split())
	l = [int(x) for x in input().split()]
	ans.append(rep_element(l, d))
for i in ans:
	print(i)


a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	d = list(map(int, input().split()))
	m = min(d)
	f = 0
	d.pop(d.index(m))
	if m + min(d) <= c:
		print('YES')
		f = 1
	else:
		for y in range(b - 1):
			if d[y] > c:
				print('NO')
				f = 1
				break
		if f == 0:
			print('YES')


t = int(input())
for t1 in range(t):
	data1 = input().split(' ')
	d = int(data1[1])
	data2 = input().split(' ')
	arr1 = []
	for data in data2:
		arr1.append(int(data))
	arr1.sort()
	if arr1[-1] <= d or arr1[0] + arr1[1] <= d:
		print('YES')
	else:
		print('NO')


def replace(a, arr):
	if max(arr) <= a:
		return 'YES'
	arr = sorted(arr)
	if arr[0] + arr[1] <= a:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	(a, b) = map(int, input().strip().split())
	lst = list(map(int, input().strip().split()))
	print(replace(b, lst))


import math
for a0 in range(int(input())):
	(n, d) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	l.sort()
	if l[-1] > d:
		if l[0] + l[1] <= d:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, d) = [*map(int, input().split())]
	a = [*map(int, input().split())]
	a.sort()
	case = False
	for i in a:
		if i > d:
			case = True
			break
	if case:
		if a[0] + a[1] <= d:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


tests = int(input())
for t in range(tests):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[0] + a[1] <= d or a[n - 1] <= d:
		print('YES')
	else:
		print('NO')


def solve(n, d, a):
	for i in range(n):
		for j in range(i + 1, n):
			if a[i] + a[j] <= d:
				return True
	return max(a) <= d

def main():
	t = int(input())
	for _ in range(t):
		(n, d) = map(int, input().split())
		a = list(map(int, input().split()))
		if solve(n, d, a):
			print('YES')
		else:
			print('NO')
main()


tests = int(input())
for t in range(tests):
	(n, d) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	if A[-1] > d:
		x = A[0] + A[1]
		if x > d:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')


def solve():
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[0] + a[1] <= d or a[-1] <= d:
		print('YES')
	else:
		print('NO')
tc = int(input())
for _ in range(tc):
	solve()


t = int(input())
while t:
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)
	if max(a) <= d or a[0] + a[1] <= d:
		print('YES')
	else:
		print('NO')
	t -= 1


tt = int(input())
arrow = []
while tt > 0:
	w = input()
	w = w.split()
	n = int(w[0])
	d = int(w[1])
	a = input()
	a = a.split()
	a = list(map(int, a))
	a.sort()
	mn = a[0] + a[1]
	if mn <= d or max(a) <= d:
		ans = 'YES'
	else:
		ans = 'NO'
	arrow.append(ans)
	tt -= 1
for i in range(len(arrow)):
	print(arrow[i])


t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	already = True
	for ele in a:
		if ele > d:
			already = False
			break
	if already:
		print('YES')
		continue
	a.sort()
	print('YES' if a[0] + a[1] <= d else 'NO')


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


t = int(input())
output = []
for i in range(t):
	spam = False
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if a[0] <= d:
		output.append('YES')
		continue
	if a[-1] + a[-2] <= d:
		output.append('YES')
		continue
	output.append('NO')
for i in output:
	print(i)


for _ in range(int(input())):
	(a, d) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	s = sorted(set(l))
	flag = False
	if s[-1] <= d:
		flag = True
	if flag:
		print('YES')
	else:
		(a, b) = (l[0], l[1])
		if a + b <= d:
			print('YES')
		else:
			print('NO')


import math
answers = []

def solve(arr, d):
	leastElement = min(arr)
	lestIndex = arr.index(leastElement)
	secondLeast = min(arr[0:lestIndex] + arr[lestIndex + 1:])
	best = leastElement + secondLeast
	highest = max(arr)
	if highest <= d:
		answers.append('YES')
		return
	if best <= d:
		answers.append('YES')
	else:
		answers.append('NO')
t = int(input())
while t:
	(n, d) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	solve(arr, d)
	t -= 1
for ans in answers:
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	f = 0
	mi1 = mi2 = 1000
	for i in a:
		if i < mi1:
			(mi1, mi2) = (i, mi1)
		elif i < mi2:
			mi2 = i
		if i > d:
			f = 1
	if f:
		if mi1 + mi2 <= d:
			print('YES')
		else:
			print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	(m, d) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()[:m]]
	p = sorted(a)
	count = 0
	for i in range(m):
		if a[i] <= d or p[0] + p[1] <= d:
			count += 1
		else:
			print('NO')
			break
	if count == m:
		print('YES')


try:

	def check(arr):
		for i in arr:
			if i > d:
				return 'NO'
		return 'YES'
	t = int(input())
	while t != 0:
		(n, d) = map(int, input().split())
		arr = list(map(int, input().split()))
		arr.sort()
		sumi = arr[0] + arr[1]
		if sumi <= d:
			print('YES')
		else:
			print(check(arr))
		t -= 1
except EOFError:
	print(' ')


testcases = int(input())
for T in range(testcases):
	(n, d) = map(int, input().split())
	arr = input()
	L = [int(x) for x in arr.split()]
	L.sort()
	tag = 1
	for i in range(n):
		if L[i] > d:
			tag = 0
	if tag == 1:
		print('YES')
		continue
	if L[0] + L[1] <= d:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	p = list(map(int, input().split(' ')))
	s = sorted(list(map(int, input().split(' '))))
	b = 'YES' if s[0] + s[1] <= p[1] or s[p[0] - 1] <= p[1] else 'NO'
	print(b)


for _ in range(0, int(input())):
	(n, d) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort()
	if ar[0] <= d and ar[1] <= d and (ar[0] + ar[1] <= d) or max(ar) <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	nd = list(map(int, input().split()))
	n = nd[0]
	d = nd[1]
	arr = list(map(int, input().split()))
	arr.sort()
	flag = 0
	for i in range(n):
		if arr[i] <= d:
			continue
		elif arr[0] + arr[1] <= d:
			continue
		else:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(size, d) = input().split()
	arr = [int(i) for i in input().split()]
	arr.sort()
	d = int(d)
	if arr[-1] <= d or arr[0] + arr[1] <= d:
		print('Yes')
	else:
		print('No')


class solution:

	def answer(arr):
		out = []
		for i in arr:
			d = i[0]
			lis = i[1]
			lis.sort()
			temp = []
			for j in range(len(lis)):
				if lis[j] > d:
					if lis[0] + lis[1] > d:
						temp.append('NO')
						break
			temp.append('YES')
			if 'NO' in temp:
				temp = 'NO'
			else:
				temp = 'YES'
			out.append(temp)
			temp = []
		return out
n = int(input())
arr = []
for i in range(n):
	(m, d) = input().split()
	lis = list(map(int, input().split()))[:int(m)]
	arr.append([int(d), lis])
ans = solution.answer(arr)
for i in ans:
	print(i)


import sys
lines = sys.stdin.readlines()
cur_line = -1

def input():
	global lines, cur_line
	cur_line += 1
	return lines[cur_line][:-1]
for _ in range(int(input())):
	(n, d) = map(int, input().split())
	i = list(sorted(map(int, input().split())))
	print('YES' if max(i) <= d or i[0] + i[1] <= d else 'NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort()
	sm = sum(ar[:2])
	if sm <= d or ar[-1] <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
n_list = []
d_list = []
a_list = []
for test_case in range(t):
	(n, d) = input().split()
	n = int(n)
	n_list.append(n)
	d = int(d)
	d_list.append(d)
	a = input().split()
	a_int = []
	for each in a:
		a_int.append(int(each))
	a_list.append(a_int)
final = []
i = 0
for arrays in a_list:
	d = d_list[i]
	i += 1
	sorted_array = sorted(arrays)
	larger = []
	smaller = []
	for j in sorted_array:
		if j > d:
			larger.append(j)
		else:
			smaller.append(j)
	if len(larger) == 0:
		final.append('Yes')
	elif len(smaller) >= 2:
		if smaller[0] + smaller[1] <= d:
			final.append('Yes')
		else:
			final.append('No')
	else:
		final.append('No')
for fin in final:
	print(fin)


def solve(arr, d, n):
	arr.sort()
	sum = arr[0] + arr[1]
	flag = 1
	for i in arr:
		if i > d:
			flag = 0
	if flag == 0:
		for i in range(2, n):
			arr[i] = sum
		for i in arr:
			if i > d:
				return 'No'
	return 'Yes'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(solve(arr, m, n))


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	summ = a[0] + a[1]
	con = 0
	for i in range(n):
		if a[i] > d:
			con = 1
			break
	if con == 0:
		print('YES')
	elif summ <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[-1] > d:
		print('YES' if sum(a[:2]) <= d else 'NO')
	else:
		print('YES')


class main:
	T = int(input())
	while T > 0:
		T -= 1
		tmp = list(map(int, input().split()))
		(n, d) = (tmp[0], tmp[1])
		a = list(map(int, input().split()))
		a = sorted(a)
		if a[0] + a[1] <= d or a[len(a) - 1] <= d:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	ok = True
	for x in arr:
		if x > d:
			ok = False
			break
	if ok:
		print('YES')
	else:
		arr.sort()
		if arr[0] + arr[1] <= d:
			print('YES')
		else:
			print('NO')


t = int(input())
for x in range(t):
	a = input().split()
	(n, d) = map(int, a)
	arr = input().split()
	arr = list(map(int, arr))
	arr.sort()
	for x in range(len(arr)):
		if arr[x] > d:
			if arr[0] + arr[1] <= d:
				arr[x] = arr[0] + arr[1]
	r = 0
	for _ in arr:
		if _ > d:
			r = 1
	if r == 0:
		print('Yes')
	if r == 1:
		print('No')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	lis = list(map(int, input().split()))
	lis.sort()
	flag = True
	for i in lis:
		if i > d:
			flag = False
			break
	if flag:
		print('YES')
	elif lis[0] + lis[1] <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, d) = map(int, input().split())
	arr = sorted(list(map(int, input().split())))
	if arr[n - 1] <= d:
		print('YES')
		continue
	if arr[0] > d:
		print('NO')
		continue
	if arr[0] + arr[1] > d:
		print('NO')
		continue
	print('YES')


for _ in [0] * int(input()):
	(n, d) = map(int, input().split())
	A = list(map(int, input().split()))
	flag = True
	A.sort()
	a = A[0]
	b = A[1]
	for i in range(n):
		if A[i] > d:
			if a + b > d:
				flag = False
				break
	print('YES' if flag else 'NO')


for i in range(int(input())):
	(n, d) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	c = 0
	for j in range(n):
		if arr[j] <= d:
			c += 1
	if c == n or (arr[0] <= d and arr[1] <= d and (arr[0] + arr[1] <= d)):
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	(n, d) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	b = True
	for e in arr:
		if e > d:
			b = False
			break
	if b:
		print('YES')
		continue
	if arr[0] + arr[1] <= d:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for q in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, d) = (L[0], L[1])
	ch = input()
	L = [int(i) for i in ch.split()]
	L.sort()
	if L[-1] <= d:
		print('YES')
	elif L[0] + L[1] <= d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, n) = map(int, input().split())
	lijst = list(map(int, input().split()))
	lijst.sort()
	if min(lijst[0] + lijst[1], lijst[-1]) > n:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(number_of_elements, target_value) = map(int, input().split())
	array = list(map(int, input().split()))
	if max(array) <= target_value:
		print('YES')
		continue
	array.sort()
	if array[0] + array[1] <= target_value:
		print('YES')
	else:
		print('NO')