You are playing a game called Slime Escape. The game takes place on a number line. Initially, there are $n$ slimes. For all positive integers $i$ where $1 \le i \le n$, the $i$-th slime is located at position $i$ and has health $a_i$. You are controlling the slime at position $k$.

There are two escapes located at positions $0$ and $n+1$. Your goal is to reach any one of the two escapes by performing any number of game moves.

In one game move, you move your slime to the left or right by one position. However, if there is another slime in the new position, you must absorb it. When absorbing a slime, the health of your slime would be increased by the health of the absorbed slime, then the absorbed slime would be removed from the game.

Note that some slimes might have negative health, so your health would decrease when absorbing such slimes.

You lose the game immediately if your slime has negative health at any moment during the game.

Can you reach one of two escapes by performing any number of game moves, without ever losing the game?


-----Input-----

Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 20000$) — the number of test cases. Description of the test cases follows.

The first line of each test case contains two positive integers $n$, $k$ ($3 \leq n \leq 200000$, $1 \leq k \leq n$) — the number of slimes and the position of your slime.

The second line of each test case contains $n$ integers, $a_1, a_2, \ldots, a_n$ ($-10^9 \leq a_i \leq 10^9$) — the health of the slimes.

It is guaranteed that health of your slime is non-negative ($a_k \geq 0$), and all other slimes have non-zero health ($a_i \ne 0$ for $i \ne k$).

It is guaranteed that the sum of $n$ over all test cases does not exceed $200000$.


-----Output-----

For each test case, print "YES" (without quotes) if you can escape without losing, and "NO" (without quotes) otherwise.


-----Examples-----

Input
6
7 4
-1 -2 -3 6 -2 -3 -1
3 1
232 -500 -700
7 4
-1 -2 -4 6 -2 -4 -1
8 4
-100 10 -7 6 -2 -3 6 -10
8 2
-999 0 -2 3 4 5 6 7
7 3
7 3 3 4 2 1 1
Output
YES
YES
NO
YES
NO
YES


-----Note-----

In the first test case, you control the slime at position $4$ with health $6$. One way to escape is to absorb the slimes at positions $5$, $6$, and $7$. Your slime escapes with $0$ health at position $8$.

In the second test case, you control the slime with $232$ health at position $1$. Since your slime is already located next to the escape at position $0$, you can move to it without absorbing any slime.

In the third test case, it can be shown that your slime would always have a negative health before reaching any one of two escapes.

In the fourth test case, you control the slime at position $4$ with health $6$. The following describes a possible sequence of moves to win:

Absorb the slimes at positions $5$, $6$, and $7$: your health becomes $4$ after absorbing the slime with health $-2$; becomes $1$ after absorbing the slime with health $-3$; and becomes $7$ after absorbing the slime with health $6$.

Absorb the slimes at positions $3$, and $2$: your health becomes $7-7+10=10$.

Absorb the slime at position $8$: your health becomes $10-10=0$.

Use the escape at position $9$.

Since your slime has maintained non-negative health at all times, you have won.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Dynamic programming

Data structures

Amortized analysis

Greedy algorithms


Solutions:
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	r = k
	k -= 1
	l = k - 1
	x = y = 0
	mr = ml = 0
	while l >= 0 and r < n:
		if r < n and a[k] + a[r] + y + ml >= 0:
			y += a[r]
			mr = max(y, mr)
			r += 1
		elif l >= 0 and a[k] + a[l] + x + mr >= 0:
			x += a[l]
			ml = max(x, ml)
			l -= 1
		else:
			break
	if l == -1 or r == n:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	a = list(map(int, input().split()))
	if p == 1 or p == n:
		print('YES')
	else:
		x = a[:p - 1]
		x = list(reversed(x))
		y = a[p:]
		s = a[p - 1]
		i = 0
		j = 0
		nx = len(x)
		ny = len(y)
		r = 'YES'
		mx = a[p - 1]
		xi = -1
		yi = -1
		while True:
			mc = 0
			s = mx
			for i in range(xi + 1, nx):
				s += x[i]
				if s > mx:
					mx = s
					xi = i
					mc = 1
				elif s < 0:
					break
			if s >= 0:
				break
			else:
				s = mx
				for i in range(yi + 1, ny):
					s += y[i]
					if s > mx:
						mx = s
						yi = i
						mc = 1
					elif s < 0:
						break
				if s >= 0:
					break
				elif mc == 0:
					r = 'NO'
					break
		print(r)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k -= 1
	m1 = a[k]
	m2 = a[k]
	s = a[k]
	f1 = True
	f2 = True
	dk1 = k
	sd1 = s
	dk2 = k
	sd2 = s
	DL1 = dk1
	DL2 = dk2
	DL11 = 0
	DL22 = 0
	while f1 and f2:
		while sd1 + DL22 >= 0 and dk1 < n - 1:
			dk1 += 1
			sd1 += a[dk1]
			if sd1 > m1:
				m1 = sd1
				DL11 = m1 - s
		if dk1 == n - 1 and sd1 + DL22 >= 0:
			f2 = False
		sd1 -= a[dk1]
		dk1 -= 1
		while sd2 + DL11 >= 0 and dk2 > 0:
			dk2 -= 1
			sd2 += a[dk2]
			if sd2 > m2:
				m2 = sd2
				DL22 = m2 - s
		if dk2 == 0 and sd2 + DL11 >= 0:
			f2 = False
		sd2 -= a[dk2]
		dk2 += 1
		if DL2 == dk2 and DL1 == dk1:
			f1 = False
		DL1 = dk1
		DL2 = dk2
	if not f2:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().strip()
INF = float('inf')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	k -= 1
	(L, R) = ([], [])
	(sm, mn) = (0, INF)
	for i in range(k - 1, -1, -1):
		sm += a[i]
		mn = min(mn, sm)
		if sm >= 0 or i == 0:
			L.append([sm, mn])
			(sm, mn) = (0, INF)
	for i in range(k + 1, n, +1):
		sm += a[i]
		mn = min(mn, sm)
		if sm >= 0 or i == n - 1:
			R.append([sm, mn])
			(sm, mn) = (0, INF)
	(L.reverse(), R.reverse())
	h = a[k]
	while len(L) > 0 and len(R) > 0:
		if L[-1][1] + h >= 0:
			h += L[-1][0]
			L.pop()
		elif R[-1][1] + h >= 0:
			h += R[-1][0]
			R.pop()
		else:
			break
	print('YES' if len(L) == 0 or len(R) == 0 else 'NO')