New Year is coming! Vasya has prepared a New Year's verse and wants to recite it in front of Santa Claus.

Vasya's verse contains $n$ parts. It takes $a_i$ seconds to recite the $i$-th part. Vasya can't change the order of parts in the verse: firstly he recites the part which takes $a_1$ seconds, secondly — the part which takes $a_2$ seconds, and so on. After reciting the verse, Vasya will get the number of presents equal to the number of parts he fully recited.

Vasya can skip at most one part of the verse while reciting it (if he skips more than one part, then Santa will definitely notice it).

Santa will listen to Vasya's verse for no more than $s$ seconds. For example, if $s = 10$, $a = [100, 9, 1, 1]$, and Vasya skips the first part of verse, then he gets two presents.

Note that it is possible to recite the whole verse (if there is enough time). 

Determine which part Vasya needs to skip to obtain the maximum possible number of gifts. If Vasya shouldn't skip anything, print 0. If there are multiple answers, print any of them.

You have to process $t$ test cases.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

The first line of each test case contains two integers $n$ and $s$ ($1 \le n \le 10^5, 1 \le s \le 10^9$) — the number of parts in the verse and the maximum number of seconds Santa will listen to Vasya, respectively.

The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the time it takes to recite each part of the verse.

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


-----Output-----

For each test case print one integer — the number of the part that Vasya needs to skip to obtain the maximum number of gifts. If Vasya shouldn't skip any parts, print 0.


-----Example-----
Input
3
7 11
2 9 1 3 18 1 4
4 35
11 9 10 7
1 8
5

Output
2
1
0



-----Note-----

In the first test case if Vasya skips the second part then he gets three gifts.

In the second test case no matter what part of the verse Vasya skips.

In the third test case Vasya can recite the whole verse.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Implementation

Complete search


Solutions:
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	x = 0
	ans = 0
	f = 0
	id = 0
	for i in range(a):
		x += l[i]
		if ans < l[i]:
			ans = l[i]
			id = i
		if x > b:
			f = 1
			break
	print(id + 1 if f == 1 else '0')


t = int(input())
while t > 0:
	(n, s) = map(int, input().split())
	A = list(map(int, input().split()))
	c_max = -1
	c_ind = 0
	summ = 0
	if sum(A) <= s:
		print(0)
	else:
		for i in range(0, n):
			summ += A[i]
			if A[i] > c_max:
				c_max = A[i]
				c_ind = i
			if summ > s:
				break
		print(c_ind + 1)
	t = t - 1


def test(n, s):
	a = list(map(int, input().split()))
	max_i = 0
	c = 0
	stop = 0
	for i in range(n):
		if s - a[i] >= 0:
			s -= a[i]
			c += 1
			if a[i] > a[max_i]:
				max_i = i
		else:
			if a[i] > a[max_i]:
				max_i = i
				stop = i + 1
			else:
				stop = i
			break
	if c == n:
		print(0)
		return
	else:
		c2 = c - 1
		s += a[max_i]
		for i in range(stop, n):
			if s - a[i] >= 0:
				s -= a[i]
				c2 += 1
			else:
				break
		if c2 >= c:
			print(max_i + 1)
			return
		else:
			print(0)
			return
for i in range(int(input())):
	(n, s) = map(int, input().split())
	test(n, s)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	M = list(map(int, input().split()))
	cnt = 0
	ans = 0
	ma = 0
	ind = 0
	f = True
	for i in range(n - 1):
		cnt += M[i]
		if M[i] > ma:
			ma = M[i]
			ind = i + 1
		if cnt > s:
			if f:
				if ma > M[i + 1]:
					ans = ind
				f = False
			else:
				break
	print(ans)


import sys

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class BIT:

	def __init__(self, n):
		nv = 1
		while nv < n:
			nv *= 2
		self.size = nv
		self.tree = [0] * nv

	def sum(self, i):
		s = 0
		i += 1
		while i > 0:
			s += self.tree[i - 1]
			i -= i & -i
		return s

	def add(self, i, x):
		i += 1
		while i <= self.size:
			self.tree[i - 1] += x
			i += i & -i

	def get(self, l, r=None):
		if r is None:
			r = l + 1
		res = 0
		if r:
			res += self.sum(r - 1)
		if l:
			res -= self.sum(l - 1)
		return res

	def bisearch_back(self, l, r, x):
		r_sm = self.sum(r)
		ok = l - 1
		ng = r + 1
		while ok + 1 < ng:
			mid = (ok + ng) // 2
			if r_sm - self.sum(mid - 1) >= x:
				ok = mid
			else:
				ng = mid
		if ok != l - 1:
			return ok
		else:
			return -1

	def bisearch_fore(self, l, r, x):
		l_sm = self.sum(l - 1)
		ok = r + 1
		ng = l - 1
		while ng + 1 < ok:
			mid = (ok + ng) // 2
			if self.sum(mid) - l_sm >= x:
				ok = mid
			else:
				ng = mid
		if ok != r + 1:
			return ok
		else:
			return -1
for _ in range(INT()):
	(N, K) = MAP()
	A = LIST()
	if sum(A) <= K:
		print(0)
		continue
	bit = BIT(N)
	for (i, a) in enumerate(A):
		bit.add(i, a)
	mx = 0
	for i in range(N):
		bit.add(i, -A[i])
		idx = bit.bisearch_fore(0, N - 1, K + 1)
		if idx == -1:
			mx = INF
			ans = i + 1
		elif idx > mx:
			mx = idx
			ans = i + 1
		bit.add(i, A[i])
	print(ans)


def ain():
	return map(int, input().split())
for _ in range(int(input())):
	(n, s) = ain()
	l = list(ain())
	t = 0
	c = 0
	max = 0
	flag = 0
	ind = 0
	for i in range(n):
		x = l[i]
		if l[max] < x:
			max = i
		if t + x > s:
			if flag == 1:
				break
			else:
				flag = 1
				ind = max
				c -= 1
				if max == i:
					c += 1
					continue
				else:
					t -= l[max]
					if t + x > s:
						break
					else:
						c += 1
						continue
		if t + x <= s:
			t += x
			c += 1
	if flag == 1:
		print(ind + 1)
	else:
		print(0)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, s) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	ix = 0
	for i in range(n):
		if a[i] > a[ix]:
			ix = i
		s -= a[i]
		if s < 0:
			break
	if s >= 0:
		ix = -1
	print(ix + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	A = list(map(int, input().split()))
	cplt = 0
	acc = 0
	for a in A:
		acc += a
		if acc <= s:
			cplt += 1
		else:
			acc -= a
			break
	res = 0
	if n > cplt:
		maxi = 0
		for i in range(cplt + 1):
			if A[i] > A[maxi]:
				maxi = i
		res = maxi + 1
	print(res)


import math
t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	summ = sum(a)
	if s >= summ:
		print('0')
	elif summ - min(a) <= s:
		print('1')
	else:
		ss = 0
		mx = -5
		ans = 0
		for i in range(len(a)):
			ss = ss + a[i]
			if a[i] > mx:
				mx = a[i]
				ans = i + 1
			if ss > s:
				break
		print(ans)


q = int(input())
for _ in range(q):
	(n, d) = map(int, input().split())
	a = list(map(int, input().split()))
	id = 0
	for i in range(n):
		if a[i] > a[id]:
			id = i
		d -= a[i]
		if d < 0:
			break
	if d >= 0:
		id = -1
	print(id + 1)


t = int(input())
while t:
	(n, s) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	flag = 1
	summ = 0
	maxm = 0
	maxmi = -1
	for i in range(0, len(l)):
		summ += l[i]
		if maxm < l[i]:
			maxm = l[i]
			maxmi = i + 1
		if summ > s:
			flag = 0
			break
	print(0 if flag else maxmi)
	t = t - 1


t = int(input())

def solve():
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	maxId = -1
	maxVerse = 0
	i = 0
	while i < n and a[i] <= s:
		s -= a[i]
		if a[i] > maxVerse:
			maxId = i
			maxVerse = a[i]
		i += 1
	if i == n:
		print(0)
		return
	if a[i] <= maxVerse:
		print(maxId + 1)
		return
	if a[i] > maxVerse:
		print(i + 1)
		return
for _ in range(t):
	solve()


import sys
t = 1
t = int(input())
for i in range(t):
	(n, s) = list(map(int, sys.stdin.readline().strip().split()))
	a = list(map(int, sys.stdin.readline().strip().split()))
	mtl = 0
	stl = 0
	j = 0
	s1 = 0
	while j < n and stl + a[j] <= s:
		stl = stl + a[j]
		s1 = s1 + 1
		if a[j] > a[mtl]:
			mtl = j
		j += 1
	if j == n:
		print(0)
	else:
		if a[j] > a[mtl]:
			mtl = j
		a.pop(mtl)
		n = n - 1
		stl2 = 0
		j = 0
		s2 = 0
		while j < n and stl2 + a[j] <= s:
			stl2 = stl2 + a[j]
			s2 = s2 + 1
			j += 1
		if s2 > s1:
			print(mtl + 1)
		else:
			print(0)


t = int(input())
for q in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	p = 0
	q = 0
	flag = 0
	for i in range(n):
		c += a[i]
		if p < a[i]:
			p = a[i]
			q = i
		if c > s:
			flag = 1
			break
	if flag == 0:
		print(0)
	else:
		print(q + 1)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	s = 0
	while i < n:
		if a[i] > a[s]:
			s = i
		m -= a[i]
		if m < 0:
			break
		i += 1
	if m >= 0:
		s = -1
	print(s + 1)


import sys
q = int(input())
results = []
for _ in range(q):
	(n, s) = map(int, input().split())
	a = list(map(int, next(sys.stdin).split(' ')))
	prev_max = a[0]
	j_max = 0
	result = 0
	for (j, i) in enumerate(a):
		s -= i
		if i >= prev_max:
			prev_max = i
			j_max = j
		if s < 0:
			result = j_max + 1
			break
	results.append(str(result))
print('\n'.join(results))


def gift():
	for _ in range(t):
		(n, s) = [int(x) for x in input().split()]
		(*a,) = [int(x) for x in input().split()]
		res = 0
		ma = 0
		max_ind = 1
		for i in range(n):
			cur = a[i]
			if cur > ma:
				ma = cur
				max_ind = i + 1
			if res + cur > s:
				yield max_ind
				break
			res += cur
		else:
			yield 0
t = int(input())
ans = gift()
print(*ans, sep='\n')


import math
testCases = int(input())
for _ in range(testCases):
	(n, s) = tuple(map(int, input().split()))
	verse = tuple(map(int, input().split()))
	mx = 0
	sm = 0
	for index in range(n):
		mx = max(mx, verse[index])
		sm += verse[index]
		if sm > s:
			print(verse.index(mx) + 1)
			break
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	time = 0
	max_part = -1
	ind = 0
	for j in range(n):
		k = a[j]
		if k > max_part:
			ind = j + 1
			max_part = k
		time += k
		if time > s:
			print(ind)
			break
	else:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ind = 0
	for i in range(n):
		if a[i] > a[ind]:
			ind = i
		s -= a[i]
		if s < 0:
			break
	print(0 if s >= 0 else ind + 1)


t = int(input())
for x in range(t):
	k = 0
	f = 0
	p = 0
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	for y in range(n):
		k = k + a[y]
		if a[y] > f:
			p = y
			f = a[y]
		if k > s:
			print(p + 1)
			break
	else:
		print('0')


for _ in range(int(input())):
	(k, m) = map(int, input().split())
	s = list(map(int, input().split()))
	ch = 0
	ans = 0
	maxx = 0
	id = 0
	i = 0
	while ch < m and i < k:
		ch += s[i]
		if s[i] > maxx:
			maxx = s[i]
			id = i + 1
		i += 1
	if ch > m:
		ans = id
	else:
		check = False
		ch -= s[id - 1]
		if i < k and s[i] + ch <= m:
			check = True
		if check:
			ans = id
	print(ans)


from sys import stdin, stdout
t = int(stdin.readline().strip())
for i in range(t):
	(n, m) = map(int, stdin.readline().strip().split())
	s = list(map(int, stdin.readline().strip().split()))
	acum = [0 for i in range(n + 5)]
	for i in range(n):
		acum[i] = s[i]
		if i > 0:
			acum[i] += acum[i - 1]
	mx = -1
	ind = -1
	ans = -1
	if acum[n - 1] <= m or (n == 1 and s[0] > m):
		print(0)
		continue
	for i in range(n):
		if s[i] > mx:
			mx = s[i]
			ind = i
		y = acum[i] - mx
		if y <= m:
			ans = ind + 1
	print(ans)


tests = int(input())
for te in range(tests):
	(n, s) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	pref = [0 for i in range(n)]
	pref[0] = arr[0]
	for i in range(1, n):
		pref[i] = pref[i - 1] + arr[i]
	if pref[n - 1] <= s:
		print(0)
		continue
	maxa = -1
	answer = -1
	for i in range(n):
		score = s + arr[i]
		low = 0
		high = n - 1
		index = -1
		while low <= high:
			mid = (low + high) // 2
			if mid >= i and score >= pref[mid]:
				index = mid
				low = mid + 1
			elif mid < i and s >= pref[mid]:
				index = mid
				low = mid + 1
			else:
				high = mid - 1
		if maxa < index:
			maxa = index
			answer = i
	if answer == -1:
		print(0)
	else:
		print(answer + 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	A = list(map(int, input().split()))
	if sum(A) <= s:
		print(0)
		continue
	max_a = 0
	max_idx = -1
	flag = False
	for i in range(n):
		s -= A[i]
		if A[i] > max_a:
			s += A[i]
			s -= max_a
			max_a = A[i]
			if s >= 0:
				max_idx = i + 1
			else:
				break
		if s < 0:
			break
	print(max_idx)


t = int(input())
for _ in range(t):
	(n, s) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	i = 0
	while i < n and s >= arr[i]:
		s -= arr[i]
		i += 1
	if i == n:
		print(0)
		continue
	maxi = arr[0]
	max_index = 1
	for j in range(i):
		if arr[j] > maxi:
			maxi = arr[j]
			max_index = j + 1
	if arr[i] > maxi + s:
		if i < n - 1:
			if s >= arr[i + 1]:
				print(i + 1)
			else:
				print(0)
		else:
			print(0)
	else:
		if arr[i] > maxi:
			max_index = i + 1
		print(max_index)


t = int(input())
ans = list()
for i in range(t):
	(n, s) = map(int, input().split())
	a = [int(j) for j in input().split()]
	su = 0
	ma = a[0]
	flag = False
	mind = 0
	ind = 0
	for j in range(n):
		su += a[j]
		if a[j] > ma:
			ma = a[j]
			mind = j
		if su > s:
			su -= ma
			if flag:
				break
			ind = mind + 1
			flag = True
	ans.append(ind)
for i in range(t):
	print(ans[i])


def solve():
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	sum1 = 0
	idx = -1
	max1 = 0
	l = list(map(int, input().split()))
	if sum(l) <= x:
		print(0)
	else:
		for i in range(n):
			sum1 += l[i]
			if sum1 > x:
				idx = i
				break
		for i in range(idx + 1):
			if max1 < l[i]:
				max1 = l[i]
				idx = i
		print(idx + 1)
t = int(input())
while t > 0:
	solve()
	t -= 1


for _ in range(int(input())):
	(p, q) = map(int, input().split())
	sum = 0
	flg = 0
	A = list(map(int, input().split()))
	m = 0
	for i in range(p):
		if A[i] > q:
			print(i + 1)
			flg = 1
			break
		else:
			sum += A[i]
			m = max(m, A[i])
		if sum > q:
			print(A.index(m) + 1)
			flg = 1
			break
	if flg == 0:
		print(0)


t = int(input())
for k in range(t):
	max = 0
	su = 0
	ind = 0
	c = 0
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(len(a)):
		su += a[i]
		if su > s:
			max = 0
			for j in range(i + 1):
				if a[j] > max:
					max = a[j]
					ind = j + 1
			break
	if c == 0:
		print(ind)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, s) = inputnums()
	a = inputlist()
	mx = 0
	ind = 0
	ans = 0
	done = False
	for i in range(n):
		if not done and a[i] > mx:
			ind = i
			mx = a[i]
		if s >= a[i]:
			s -= a[i]
			ans += 1
		elif not done:
			done = True
			s += mx
			ans -= 1
	if ans == n:
		print(0)
	else:
		print(ind + 1)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = 0
	for i in range(n):
		if arr[i] > arr[mx]:
			mx = i
		m -= arr[i]
		if m < 0:
			break
	if m >= 0:
		print(0)
	else:
		print(mx + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	t = 0
	maz = 0
	for i in range(0, n):
		t = t + l[i]
		if l[maz] < l[i]:
			maz = i
		if t > s:
			t = t - l[maz]
			print(maz + 1)
			break
	else:
		print(0)


def main():
	t = int(input())
	for k in range(t):
		line = input().split()
		(n, s) = (int(line[0]), int(line[1]))
		nums = list(map(int, input().split()))
		max_pos = -1
		total = 0
		i = 0
		while i < n:
			total += nums[i]
			if total > s:
				if max_pos == -1:
					print(1)
				elif nums[i] > nums[max_pos]:
					print(i + 1)
				else:
					print(max_pos + 1)
				break
			if max_pos == -1 or nums[i] > nums[max_pos]:
				max_pos = i
			i += 1
		if total <= s and i == n:
			print(0)
main()


import os
import sys
from io import BytesIO, IOBase

def solve(n, s, a):
	(maxa, suma) = ([a[0]], [a[0]])
	for i in range(1, n):
		maxa.append(max(a[i], maxa[-1]))
		suma.append(a[i] + suma[-1])
	for i in range(n):
		if suma[i] > s:
			return a.index(maxa[i]) + 1
	return 0

def main():
	for _ in range(int(input().strip())):
		[n, s] = map(int, input().strip().split())
		a = list(map(int, input().strip().split()))
		print(solve(n, s, a))
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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()
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


t = int(input())
inf = 10 ** 18
for _ in range(t):
	(n, s) = map(int, input().split())
	song = list(map(int, input().split()))
	dp = [inf] * (n + 1)
	dp_skipped = [inf] * (n + 1)
	skip = [0] * (n + 1)
	dp[0] = 0
	for i in range(n):
		if dp[i] != inf:
			if dp[i] + song[i] <= s:
				dp[i + 1] = dp[i] + song[i]
			dp_skipped[i + 1] = dp[i]
			skip[i + 1] = i + 1
		if dp_skipped[i] != inf:
			if dp_skipped[i] + song[i] <= s and dp_skipped[i + 1] > dp_skipped[i] + song[i]:
				dp_skipped[i + 1] = dp_skipped[i] + song[i]
				skip[i + 1] = skip[i]
	for i in range(n, -1, -1):
		if dp[i] != inf:
			print(0)
			break
		if dp_skipped[i] != inf:
			print(skip[i])
			break


import bisect

def solve(verse, n, s):
	total = 0
	count = 0
	dp = []
	max_val = 0
	ans = 0
	for i in verse:
		if not dp:
			dp.append(i)
		else:
			dp.append(dp[-1] + i)
	for i in range(n):
		index = bisect.bisect(dp, s + dp[i]) - 1
		if index > max_val:
			max_val = index
			ans = i + 1
		s -= verse[i]
		if s < 0:
			break
	if s >= 0:
		print(0)
	else:
		print(ans)

def main():
	t = int(input())
	for i in range(t):
		(n, s) = map(int, input().split())
		verse = list(map(int, input().split()))
		solve(verse, n, s)
main()


q = int(input())
for _ in range(q):
	(n, s) = [int(t) for t in input().split(' ')]
	a = [int(t) for t in input().split(' ')]
	summy = 0
	maxy = 0
	maxi = -1
	for (i, ai) in enumerate(a):
		summy += ai
		if maxy < ai:
			maxy = ai
			maxi = i
		if summy > s:
			if summy - maxy <= s:
				print(maxi + 1)
			else:
				print(0)
			break
	else:
		print(0)


for q11 in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	pref = [0]
	for q in range(n):
		pref.append(pref[-1] + a[q])
	if pref[-1] <= k:
		print(0)
	else:
		ans = [-1, -1]
		for q in range(n):
			if pref[q] <= k:
				(l, r) = (0, n)
				while r - l > 1:
					m = (l + r) // 2
					if pref[m + 1] - a[q] <= k:
						l = m
					else:
						r = m
				ans = max([l - 1, q], ans)
		print(ans[1] + 1)


t = int(input())
for i in range(t):
	(n, s) = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	e = 0
	k = 0
	for j in range(len(a)):
		e = e + a[j]
		if e > s:
			k = j
			break
	c = a[:min(n + 1, k + 1)]
	d = max(c)
	if sum(c) <= s:
		print(0)
	else:
		print(c.index(d) + 1)


for _ in range(int(input())):
	(n, t) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	ind = 0
	for j in range(n):
		if lst[j] > lst[ind]:
			ind = j
		t -= lst[j]
		if t < 0:
			break
	if t >= 0:
		ind = -1
	print(ind + 1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

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))
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 graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

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

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

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def bs(a, l, h, x):
	while l < h:
		mid = (l + h) // 2
		if a[mid] == x:
			return mid
		if a[mid] < x:
			l = mid + 1
		else:
			h = mid
	return l

def sieve(a):
	for i in range(3, 10 ** 6 + 1, 2):
		a[i] = 1
	for i in range(3, 10 ** 6 + 1, 2):
		for j in range(i * i, 10 ** 6 + 1, i):
			a[j] = 0
	a[2] = 1
	return a

def bfs(g, st):
	visited = [0] * len(g)
	visited[st] = 1
	queue = []
	queue.append(st)
	new = []
	while len(queue) != 0:
		s = queue.pop()
		new.append(s)
		for i in g[s]:
			if visited[i] == 0:
				visited[i] = 1
				queue.append(i)
	return new

def solve():
	(n, ss) = sep()
	a = lis()
	m = 0
	if sum(a) <= ss:
		print(0)
		return
	summ = 0
	for i in range(0, n):
		m = max(m, a[i])
		summ += a[i]
		ind = i
		if summ > ss:
			break
	cnt = 0
	s = 0
	for i in range(ind + 1, n):
		s += a[i]
		if s > m:
			break
		cnt += 1
	print(a.index(m) + 1)
testcase(int(inp()))


for i in range(int(input())):
	(a, s) = map(int, input().split())
	l = [int(x) for x in input().split()]
	d = 0
	ff = 1
	if sum(l) > s:
		ff = 0
		for j in range(len(l)):
			d = d + l[j]
			if d > s:
				h = j
				break
	if ff == 0:
		print(l.index(max(l[:h + 1])) + 1)
	else:
		print('0')


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	(ans, sm) = (0, 0)
	for i in range(n):
		sm += a[i]
		if sm > s:
			mx = max(a[:i + 1])
			ans = a[:i + 1].index(mx)
			ans += 1
			break
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	parts = list(map(int, input().split()))
	prefix_parts = [0]
	max_seen = -math.inf
	max_seen_index = -1
	for (i, x) in enumerate(parts):
		if x > max_seen:
			max_seen = x
			max_seen_index = i
		next_value = prefix_parts[-1] + x
		if next_value <= s:
			prefix_parts.append(next_value)
		else:
			break
	if len(prefix_parts) > len(parts):
		print(0)
	else:
		next_index = len(prefix_parts) - 1
		if parts[next_index] <= max_seen:
			print(max_seen_index + 1)
		else:
			print(0)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	b = 0
	sum = 0
	for i in range(n):
		sum += a[i]
		if a[i] > a[b]:
			b = i
		if sum > s:
			break
	if sum <= s:
		print(0)
	else:
		print(b + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	arrs = list(map(int, input().split()))
	cur_max = 0
	ss = 0
	skip = 0
	for (i, num) in enumerate(arrs):
		ss += num
		if ss <= s:
			if num > cur_max:
				cur_max = num
				skip = i + 1
		else:
			if num > cur_max:
				skip = i + 1
			break
	if ss <= s:
		print(0)
	else:
		print(skip)


a = int(input())
for i in range(0, a):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = []
	summ = 0
	for i in range(0, len(arr)):
		brr.append(arr[i])
		summ = summ + arr[i]
		if summ >= s:
			break
	if len(brr) == len(arr) or len(brr) == 0:
		print(0)
	elif max(brr) > arr[len(brr)]:
		print(brr.index(max(brr)) + 1)
	else:
		print(0)


try:
	t = int(input())
	while t > 0:
		(n, s) = [int(x) for x in input().split()]
		A = [int(x) for x in input().split()]
		Sum = 0
		for i in range(0, n):
			Sum += A[i]
		if Sum <= s:
			print(0)
			continue
		ans = 0
		Sum = 0
		flag = False
		for i in range(0, n):
			if flag == True:
				break
			if Sum + A[i] > s:
				sec = A[:i + 1]
				Sum = Sum - int(max(sec))
				ans = sec.index(max(sec)) + 1
				flag = True
			Sum += A[i]
		print(ans)
		t = t - 1
except:
	pass


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	c = [a[i] for i in range(n)]
	skip = False
	ans = 0
	for i in range(1, n):
		c[i] += c[i - 1]
		if a[ans] < a[i]:
			ans = i
		if c[i] > s:
			skip = True
			break
	if skip:
		print(ans + 1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, s) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	maxval = -1
	done = False
	skip = 0
	for i in range(n):
		if maxval == -1 or l[i] > l[maxval]:
			maxval = i
		if s >= l[i]:
			s -= l[i]
			if not done:
				skip += 1
		else:
			s -= l[i]
			if not done:
				skip = maxval
				done = True
				s += l[maxval]
			else:
				break
	skip += 1
	if skip > n:
		skip = 0
	print(skip)


def get_skipped_id(parts, lim):
	max_on_prefix_id = [0]
	sum_on_prefix = [parts[0]]
	Max = parts[0]
	for i in range(1, len(parts)):
		sum_on_prefix.append(sum_on_prefix[i - 1] + parts[i])
		if parts[i] > Max:
			max_on_prefix_id.append(i)
			Max = parts[i]
		else:
			max_on_prefix_id.append(max_on_prefix_id[-1])
	if sum_on_prefix[-1] <= lim:
		return 0
	left = 0
	right = len(parts)
	cur_ans = 1
	while left + 1 < right:
		mid = (left + right) // 2
		if sum_on_prefix[mid] - parts[max_on_prefix_id[mid]] <= lim:
			left = mid
			cur_ans = max_on_prefix_id[mid] + 1
		else:
			right = mid
	return cur_ans
test_count = int(input())
for _ in range(test_count):
	(n, s) = map(int, input().split())
	parts = list(map(int, input().split()))
	print(get_skipped_id(parts, s))


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	o = 0
	mx = 0
	cnt = 0
	for i in range(n):
		s = s - a[i]
		if a[i] > mx:
			mx = a[i]
			o = i + 1
		if s < 0:
			break
		cnt += 1
	if cnt == n:
		print(0)
	else:
		print(o)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	su = 0
	for j in a:
		su += j
	if su <= s:
		print(0)
		continue
	else:
		su = 0
		mx = a[0]
		ind = 0
		for j in range(n):
			su += a[j]
			if j != 0 and a[j] > mx:
				mx = a[j]
				ind = j
			if su > s:
				print(ind + 1)
				break


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

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

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

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

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

def main():
	t = inin()
	for _ in range(t):
		(n, k) = cin()
		a = ain()
		l = 0
		p = 0
		d = {}
		ans = 0
		for i in range(n):
			p = max(a[i], p)
			d[a[i]] = i + 1
			if a[i] + l <= k:
				l += a[i]
			else:
				ans = d[p]
				break
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


import sys
import math
from collections import Counter
import bisect
ma = lambda : map(int, input().split())
inp = lambda : [int(i) for i in input().split()]
s = sorted
for _ in range(int(input())):
	(n, s) = ma()
	a = inp()
	val = 0
	maxi = 0
	ind = 0
	flag = 0
	for i in range(n):
		if val + a[i] > s:
			if maxi > a[i]:
				print(ind + 1)
				flag = 1
				break
			else:
				print(i + 1)
				flag = 1
				break
		else:
			val += a[i]
			if a[i] > maxi:
				ind = i
				maxi = a[i]
	if flag == 0:
		print(0)


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	(n, s) = list(map(int, sys.stdin.readline().strip().split()))
	a = list(map(int, sys.stdin.readline().strip().split()))
	p = 0
	m = 0
	l = 0
	j = 0
	for i in range(0, n):
		l = l + a[i]
		if a[i] > m:
			j = i
			m = a[i]
		if l <= s:
			p = 0
		elif l - m <= s:
			p = j + 1
	print(p)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(m, s, ind) = (float('inf'), 0, 0)
	for (i, el) in enumerate(map(int, input().split())):
		if s - (m if el < m else el) + el > k:
			break
		if m == float('inf'):
			m = el
			ind = 1
		if el > m:
			ind = i + 1
		m = max(el, m)
		s += el
	if s <= k:
		print(0)
	else:
		print(ind)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		pref = [a[0]]
		for i in range(1, len(a)):
			pref.append(pref[-1] + a[i])
		(x, y, c) = (0, 0, 0)
		for i in range(len(pref)):
			if pref[i] > s:
				y = i
				break
			else:
				x = max(x, a[i])
				c += 1
		ans = c - 1
		for i in range(y, len(pref)):
			if pref[i] - x <= s:
				ans += 1
			else:
				break
		(temp, r) = (0, 0)
		for i in range(len(a)):
			if i == y:
				pass
			else:
				temp += a[i]
				if temp <= s:
					r += 1
				else:
					break
		if ans > c and ans >= r:
			print(a.index(x) + 1)
		elif r > c and r >= ans:
			print(y + 1)
		else:
			print(0)


from sys import maxsize
get_int = lambda : int(input())
get_mul_int = lambda : map(int, input().rstrip().split())
get_list = lambda : list(map(int, input().rstrip().split()))
TEST_CASES = True

def main():
	(n, s) = get_mul_int()
	a = get_list()
	if n == 1:
		if s >= a[0]:
			print(0)
		else:
			print(1)
		return
	place = 0
	for i in range(n):
		if a[i] > a[place]:
			place = i
		s -= a[i]
		if s < 0:
			break
	if s >= 0:
		print(0)
		return
	else:
		print(place + 1)
if not TEST_CASES:
	main()
else:
	[main() for _ in range(int(input()))]


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

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

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

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

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
t = ii()
for _ in range(t):
	(n, s) = mi()
	a = li()
	if sum(a) <= s:
		print(0)
	else:
		max_ = i = t = 0
		while t <= s:
			if a[i] > a[max_]:
				max_ = i
			t += a[i]
			i += 1
		print(max_ + 1)


t = int(input())
for y in range(t):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	m = -1
	for i in range(n):
		s -= a[i]
		if m == -1 or a[m] < a[i]:
			m = i
		if s < 0 and m != n:
			print(m + 1)
			break
	else:
		print(0)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	line = [int(i) for i in input().split()]
	if sum(line) <= s:
		print(0)
		continue
	counter = 0
	maxx = (float('-inf'), -1)
	for (i, elem) in enumerate(line):
		counter += elem
		if elem > maxx[0]:
			maxx = (elem, i + 1)
		if counter > s:
			print(maxx[1])
			break


for u in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	f = 0
	s = 0
	for i in range(n):
		s = s + l[i]
		if s > k:
			f = i + 1
			break
	if f == 0:
		print(0)
	else:
		m = max(l[:f])
		if l[f - 1] < m:
			print(l.index(m) + 1)
		else:
			print(f)


for tc in range(int(input())):
	(n, tottime) = map(int, input().split())
	ls = list(map(int, input().split()))
	if sum(ls) <= tottime:
		print(0)
		continue
	mxseen = 0
	mxidx = 0
	totsofar = 0
	for (i, e) in enumerate(ls):
		if totsofar + e - max(e, mxseen) > tottime:
			break
		totsofar += e
		if mxseen < e:
			mxseen = e
			mxidx = i + 1
		if totsofar - mxseen > tottime:
			break
	print(mxidx)


for nt in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
	else:
		loc = 0
		total = 0
		ans = 0
		counts = 0
		for i in range(n):
			total += l[i]
			if total > s:
				total -= l[i]
				loc = i
				counts = i
				count = i
				break
		count = max(count - 1, 0)
		for i in range(n):
			if i < loc:
				total = max(total - l[i], 0)
				if total <= s:
					while total <= s and loc < n:
						total += l[loc]
						count += 1
						loc += 1
					if total > s:
						count -= 1
						loc -= 1
						total -= l[loc]
				if count > counts:
					counts = count
					ans = i + 1
				total += l[i]
			else:
				count += 1
				loc += 1
				while total <= s and loc < n:
					total += l[loc]
					count += 1
					loc += 1
				if total > s:
					count -= 1
					loc -= 1
					total -= l[loc]
				if count > counts:
					counts = count
					ans = i + 1
				break
		print(ans)


import sys
from collections import Counter
from math import *
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		continue
	L = 0
	R = n + 1
	ans = 0
	while R - L > 1:
		m = (L + R) // 2
		if sum(a[:m]) - max(a[:m]) > s:
			R = m
		else:
			L = m
			ans = a.index(max(a[:m]))
	print(ans + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	t = 0
	x = 0
	z = 0
	ans = 0
	k = 0
	for (i, y) in enumerate(map(int, input().split())):
		t += y
		if y > x:
			x = y
			z = i
		if t <= s:
			if i + 1 > ans:
				ans = i + 1
				k = 0
		elif t - x <= s:
			if i > ans:
				ans = i
			k = z + 1
	print(k)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	a = m = 0
	if sum(l) <= s:
		print(0)
	else:
		for i in range(n):
			a += l[i]
			m = max(l[i], m)
			if a > s:
				break
		for i in range(n):
			if l[i] == m:
				print(i + 1)
				break


import bisect
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	flag = 0
	for i in range(n):
		if a[i] > a[ans]:
			ans = i
		m -= a[i]
		if m < 0:
			flag = 1
			break
	if ans >= 0 and flag == 1:
		print(ans + 1)
	else:
		print(0)


t = int(input())
for i in range(t):
	count = 0
	ans = 0
	f = 0
	(n, s) = map(int, input().split())
	li = [int(x) for x in input().split()]
	for j in li:
		if count <= s:
			count += j
			ans += 1
		else:
			f = 1
			break
	if f == 0:
		print(0)
	else:
		print(li.index(max(li[:ans])) + 1)


t = int(input())
for i in range(t):
	s = input()
	s = s.split()[1]
	l = input()
	l = l.split()
	ans = -1
	mx = -1
	sum = 0
	for i in l:
		sum += int(i)
	if sum <= int(s):
		print('0')
	else:
		sum = 0
		for i in range(len(l)):
			sum += int(l[i])
			if int(l[i]) > mx:
				ans = i
				mx = int(l[i])
			if sum > int(s):
				print(ans + 1)
				break


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	ai = list(map(int, input().split()))
	time = 0
	maxx = 0
	ct = 0
	val = []
	for i in range(n):
		if ct == 0:
			maxx = max(maxx, ai[i])
		time += ai[i]
		if time > s and ct == 0:
			val.append((i + 1, 0))
			time -= maxx
			ct += 1
		if time > s and ct == 1:
			val.append((i, ai.index(maxx) + 1))
			ct += 1
			break
	if ct == 0:
		print(0)
	elif ct == 1:
		print(ai.index(maxx) + 1)
	elif ct == 2:
		if val[0][0] > val[1][0]:
			print(val[0][1])
		else:
			print(val[1][1])


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))

	def solve(arr, n, s):
		if s >= sum(arr):
			return 0
		index = 0
		sum_x = 0
		for i in range(n):
			sum_x += arr[i]
			if sum_x > s:
				index = i
				break
		brr = [arr[i] for i in range(index + 1)]
		return brr.index(max(brr)) + 1
	print(solve(arr, n, s))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	if sum(arr) <= b:
		print(0)
	else:
		index = -1
		s = m = 0
		for i in range(a):
			s += arr[i]
			if m != -1 and arr[i] > m:
				m = arr[i]
				index = i + 1
			if s > b:
				if m == -1 or i == a - 1:
					print(index)
					break
				s -= 1
				m = -1


for _ in range(int(input())):
	(a, s) = map(int, input().split())
	l = list(map(int, input().split()))
	j = 0
	k = -1
	for i in range(a):
		j += l[i]
		if j > s:
			k = i
			j -= l[i]
			break
	if k == -1:
		print(0)
	else:
		x = max(l[:k + 1])
		if j + sum(l[k:k + 2]) - x <= s:
			print(l.index(x) + 1)
		else:
			print(0)


t = int(input())
answers = []
for ti in range(t):
	ints = list(map(int, input().split()))
	(n, s) = (ints[0], ints[1])
	a = list(map(int, input().split()))
	if sum(a) <= s:
		answers.append('0')
		continue
	summ = 0
	mx = a[0]
	mx_index = 0
	for i in range(len(a)):
		summ += a[i]
		if summ > s:
			if a[i] < mx:
				ans = mx_index + 1
				break
		if a[i] >= mx:
			mx_index = i + 1
			mx = a[i]
	answers.append(mx_index)
for a in answers:
	print(a)


t = int(input())
while t:
	(n, s) = map(int, input().split())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	if s >= sum(a):
		print(0)
	else:
		x = 0
		y = 0
		for i in range(n):
			if s - a[i] >= 0:
				s -= a[i]
				if x <= a[i]:
					x = a[i]
					y = i
			elif a[i] >= x:
				print(i + 1)
				break
			elif i <= n - 2:
				if s + x >= a[i] + a[i + 1]:
					print(y + 1)
					break
				else:
					print(0)
					break
			else:
				print(0)
				break
	t -= 1


a = int(input())
f = []
for i in range(a):
	(f1, f2) = list(map(int, input().split()))
	g = list(map(int, input().split()))
	if sum(g) <= f2:
		f.append(0)
	elif g[0] > f2:
		f.append(1)
	elif g[0] == f2 and g[1] > f2:
		f.append(0)
	else:
		s = 0
		k = 0
		for j in g:
			s += j
			k += 1
			if s > f2:
				s -= j
				k -= 1
				break
		g1 = g[:k + 1]
		o = max(g1)
		for t in range(k + 1):
			if o == g1[t]:
				f.append(t + 1)
				break
for i in f:
	print(i)


t = int(input())
for _ in range(t):
	(n, s1) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = -1
	s = 0
	ans_idx = -1
	flg = False
	for i in range(n):
		s += arr[i]
		mx = max(mx, arr[i])
		if s > s1 and (not flg):
			flg = True
			s1 += mx
			ans_idx = arr.index(mx)
		if s > s1 and flg:
			break
	print(ans_idx + 1)


t = int(input())
for i in range(t):
	s = list(map(int, input().split()))
	n = s[0]
	t = s[1]
	a = list(map(int, input().split()))
	x = 0
	mx = 0
	i = 0
	d = 0
	while i < n:
		x += a[i]
		if a[i] > mx:
			mx = a[i]
			d = i
		if x > t:
			break
		i += 1
	k = i
	if i == n or i == n - 1:
		print('0')
	else:
		x -= a[i]
		x -= mx
		x += a[i] + a[i + 1]
		if x <= t:
			print(d + 1)
		else:
			print('0')


t = int(input())
ans = []
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * (n + 1)
	index = 0
	a_max = 0
	flag = True
	for i in range(n):
		b[i + 1] = b[i] + a[i]
		a_max = max(a_max, a[i])
		if a[index] != a_max:
			index = i
		if b[i + 1] > s:
			flag = False
			break
	if flag:
		ans.append(0)
	else:
		ans.append(index + 1)
for i in range(t):
	print(ans[i])


import sys
ip = lambda : sys.stdin.readline().rstrip()
for _ in range(int(ip())):
	(n, s) = map(int, ip().split())
	a = list(map(int, ip().split()))
	sm = sum(a)
	if sm <= s:
		print(0)
	else:
		(csum, mx) = (0, [-float('inf'), -float('inf')])
		(ans, val) = (0, 0)
		for i in range(n):
			csum += a[i]
			mx = max(mx, [a[i], i], key=lambda x: x[0])
			if csum - mx[0] <= s:
				if i > ans:
					ans = i
					val = mx[1] + 1
			else:
				break
		print(val)


t = int(input())
for i in range(t):
	(n, s) = input().strip().split(' ')
	(n, s) = [int(n), int(s)]
	x = list(map(int, input().strip().split(' ')))
	maxa = x[0]
	ii = 0
	suma = 0
	for i in range(n):
		if suma + x[i] <= s:
			suma += x[i]
			if i < n - 1 and x[i + 1] >= maxa:
				ii = i + 2
				maxa = x[i + 1]
		elif suma + x[i] > s:
			break
	if suma == sum(x) or sum(x) <= s:
		print(0)
	elif maxa == 0 or maxa == x[0]:
		print(1)
	else:
		print(ii)


def f(a, ign, s):
	pres = 0
	for i in range(len(a)):
		if i == ign:
			continue
		if s >= a[i]:
			s -= a[i]
			pres += 1
		else:
			break
	return pres
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	noint = 0
	ctr = s
	mx = a[0]
	for p in a:
		if ctr >= p:
			noint += 1
			ctr -= p
			mx = max(mx, p)
		else:
			break
	if noint == n:
		print(0)
	else:
		ans1 = noint
		v1 = -1
		ans2 = f(a, a.index(mx), s)
		v2 = a.index(mx)
		ans3 = f(a, noint, s)
		v3 = noint
		if ans1 == max(ans1, ans2, ans3):
			print(v1 + 1)
		elif ans2 == max(ans1, ans2, ans3):
			print(v2 + 1)
		else:
			print(v3 + 1)


for i in range(int(input())):
	(n, s) = map(int, input().split())
	a = [int(c) for c in input().split()]
	count = 0
	for j in range(n):
		if a[j] > a[count]:
			count = j
		s = s - a[j]
		if s < 0:
			break
	if s >= 0:
		count = -1
	print(count + 1)


test = int(input())
for it in range(test):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	idx = 0
	mm = arr[0]
	for i in range(n):
		if arr[i] > mm:
			idx = i
			mm = arr[i]
		t -= arr[i]
		if t < 0:
			break
	if t >= 0:
		idx = -1
	print(idx + 1)


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	L = list(map(int, input().split()))
	PrefixSum = [0] * N
	PrefixSum[0] = L[0]
	for i in range(1, N):
		PrefixSum[i] = PrefixSum[i - 1] + L[i]
	PrefixSum2 = []
	largest = [0] * N
	t = 0
	for i in range(N):
		if L[i] > t:
			t = L[i]
		largest[i] = PrefixSum[i] - t
	if PrefixSum[N - 1] <= K:
		print('0')
	else:
		for i in range(N):
			if largest[i] > K:
				N = i
				break
		t = 0
		for i in range(N):
			if t < L[i]:
				t = L[i]
		for i in range(N):
			if L[i] == t:
				print(i + 1)
				break


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ss = 0
	flg = 0
	for j in range(n):
		ss += a[j]
		if ss > s:
			flg = 1
			break
	if flg == 1:
		print(a[:j + 1].index(max(a[:j + 1])) + 1)
	else:
		print(0)


number = int(input())
for i in range(0, number):
	numbers = input()
	numberss = numbers.split()
	numbersss = list(map(int, numberss))
	n = numbersss[0]
	s = numbersss[1]
	ais = input().split()
	aiss = list(map(int, ais))
	maxx = 0
	maxxind = 0
	sum = 0
	for i in range(0, n):
		if aiss[i] > maxx:
			maxx = aiss[i]
			maxxind2 = i + 1
		sum = sum + aiss[i]
		sum2 = sum - maxx
		if sum2 > s:
			print(maxxind)
			break
		else:
			maxxind = maxxind2
			if i == n - 1:
				if sum2 + maxx <= s:
					print(0)
				else:
					print(maxxind)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
		continue
	total = 0
	maxim = -999
	ans = 0
	for i in range(n):
		total += l[i]
		if maxim < l[i]:
			maxim = l[i]
			ans = i + 1
		if total > s:
			break
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	l = [int(i) for i in input().split()]
	summa = 0
	ok = 0
	for i in range(n):
		summa += l[i]
		if summa > s:
			ok = 1
			break
	if ok == 1:
		print(l.index(max(l[:i + 1])) + 1)
	else:
		print(0)


for t in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	id = 0
	for i in range(n):
		if a[i] > a[id]:
			id = i
		s -= a[i]
		if s < 0:
			break
	if s >= 0:
		id = -1
	print(id + 1)


T = int(input())
for i in range(T):
	(n, s) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	su = [l[0]]
	for j in range(1, n):
		su.append(su[j - 1] + l[j])
	if su[n - 1] <= s:
		print(0)
	else:
		for j in range(n):
			if su[j] > s:
				break
		br = l[0:j + 1]
		print(br.index(max(br)) + 1)


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	a = list(map(int, input().split()))
	s = 0
	m = 0
	c = 0
	f = 0
	for i in range(n):
		if s <= p and a[i] <= p:
			s = s + a[i]
			if s > p:
				c = 1
				if m > a[i]:
					break
				else:
					pos = i + 1
					break
			if m < a[i]:
				m = a[i]
				pos = i + 1
		else:
			c = 1
			pos = i + 1
			break
	if c == 1:
		print(pos)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * n
	c = [0] * n
	for h in range(n):
		b[h] = b[h - 1] + a[h]
		c[h] = max(c[h - 1], a[h])
	for j in range(n)[::-1]:
		if b[j] <= s:
			print(0)
			break
		elif b[j] - c[j] <= s:
			print(a.index(c[j]) + 1)
			break


t = int(input(''))
for v in range(t):
	a = input('').split(' ')
	n = int(a[0])
	p = int(a[1])
	a = list(map(int, input('').split(' ')))
	su = 0
	sums = [0]
	for i in range(n):
		su = su + a[i]
		sums.append(su)
	ind = n
	for i in range(n + 1):
		if sums[i] > p:
			ind = i
			su = sums[i - 1]
			break
	if n == 1:
		print(0)
		continue
	if ind == 1:
		print(1)
		continue
	if ind == n:
		print(0)
		continue
	mx = max(a[:ind])
	for i in range(ind):
		if a[i] >= mx:
			ans = i + 1
	if a[ind] <= p - su + mx:
		print(ans)
	else:
		print(0)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, s) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	ans = [arr[0]]
	m = arr[0]
	if sum(arr) > s:
		final = 1
	else:
		final = 0
	count = 0
	for i in range(1, n):
		if m > s:
			break
		else:
			ans.append(arr[i])
			m += arr[i]
			if m > s:
				if count >= 1:
					break
				else:
					final = ans.index(max(ans)) + 1
					m -= max(ans)
					ans.remove(max(ans))
					count += 1
			else:
				pass
	print(final)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	import bisect
	arr = list(map(int, input().split()))
	pre = [0] * n
	pre[0] = arr[0]
	for i in range(1, n):
		pre[i] = pre[i - 1] + arr[i]
	var = bisect.bisect_right(pre, s)
	if var == n:
		print(0)
	elif var == 0:
		print(1)
	else:
		maxx = max(arr[:var])
		if maxx > arr[var]:
			print(arr[:var].index(maxx) + 1)
		elif var + 1 <= n - 1 and arr[var + 1] <= s - pre[var - 1]:
			print(var + 1)
		else:
			print(0)


t = int(input())
for j in range(t):
	(n, m) = map(int, input().split())
	s = 0
	l = list(map(int, input().split()))
	for i in range(len(l)):
		s = s + l[i]
	if s <= m:
		print(0)
	else:
		s = 0
		skipped = 0
		for i in range(1, len(l)):
			s = s + l[i]
			if s > s - l[i] + l[skipped]:
				s = s - l[i]
				s = s + l[skipped]
				if s > m:
					break
				else:
					skipped = i
		print(skipped + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	x = sum(l)
	if s >= x:
		print(0)
		continue
	pre = l.copy()
	for i in range(1, n):
		pre[i] += pre[i - 1]
	v = 1
	f = 0
	m = 0
	ans = 0
	pm = -1
	mi = -1
	for k in range(n):
		if f == 0 and pm < l[k]:
			pm = l[k]
			mi = k
		if pre[k] - m > s:
			if f == 0:
				f = 1
				m = l[mi]
			else:
				break
		else:
			ans = k + 1
	print(mi + 1)


def tutorial(lst, sec):
	lst = [int(i) for i in lst]
	maxSkipped = 0
	if sum(lst) <= sec:
		return 0
	for i in range(len(lst)):
		if lst[i] > lst[maxSkipped]:
			maxSkipped = i
		sec -= lst[i]
		if sec < 0:
			break
	return maxSkipped + 1

def main():
	n = eval(input())
	for i in range(n):
		sec = input()
		sec = sec.split()
		sec = eval(sec[1])
		lst = input()
		lst = lst.split()
		print(tutorial(lst, sec))
main()


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	q = 0
	(suma, maxa) = (0, (0, -1))
	for q in range(n):
		suma += a[q]
		tmaxa = max(maxa, (a[q], q))
		if suma - tmaxa[0] > s:
			break
		else:
			maxa = tmaxa
	if suma <= s:
		print(0)
	else:
		print(maxa[1] + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	A = [*map(int, input().split())]
	B = [0] * n
	M = [0] * n
	for i in range(n):
		if not i:
			M[i] = A[i]
			B[i] = A[i]
		else:
			B[i] = A[i] + B[i - 1]
			M[i] = max(M[i - 1], A[i])
	maxi = 0
	p = 0
	for i in range(n):
		acum = B[i] - M[i]
		if acum > s:
			print(p + 1)
			break
		if maxi < M[i]:
			maxi = M[i]
			p = i
	else:
		if B[i] > s:
			print(p + 1)
		else:
			print(0)


def solve(a, n, s):
	idx = 0
	for i in range(n):
		if a[i] > a[idx]:
			idx = i
		s -= a[i]
		if s < 0:
			break
	if s >= 0:
		idx = -1
	return idx + 1
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve(a, n, s))


def abc(ds, high):
	if sum(ds) <= high:
		return 0
	s = 0
	for (i, iv) in enumerate(ds):
		s += iv
		if s > high:
			hig = ds[:i + 1]
			return hig.index(max(hig)) + 1
t = int(input())
out = []
for i in range(t):
	(n, s) = map(int, input().split())
	nums = list(map(int, input().split()))
	out.append(abc(nums, s))
for i in out:
	print(i)


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = [int(x) for x in input().split()]
	index = 0
	total = 0
	seen = set()
	while index < n:
		total += a[index]
		seen.add(a[index])
		if total > s:
			break
		index += 1
	maxVal = max(seen)
	if index == n:
		print(0)
	else:
		print(a.index(maxVal) + 1)


t = int(input())
for i in range(t):
	(n, s) = input().split(' ')
	n = int(n)
	s = int(s)
	arr = list(map(lambda x: int(x), input().split(' ')))
	pre_arr = [arr[0]]
	for j in range(1, n):
		pre_arr.append(pre_arr[-1] + arr[j])
	index = -1
	while index <= n - 2:
		if pre_arr[index + 1] <= s:
			index += 1
		else:
			break
	if index == n - 1:
		ans = 0
	else:
		maximum = max(arr[0:index + 2])
		for j in range(index + 2):
			if arr[j] == maximum:
				rem_index = j
				break
		if n - 2 > index:
			if arr[index + 2] <= arr[rem_index]:
				ans = rem_index + 1
			else:
				ans = 0
		else:
			ans = 0
	print(ans)


test_cases = int(input())
for _ in range(test_cases):
	(n, s) = map(int, input().split())
	verses = list(map(int, input().split()))
	verses.append(s)
	max_verse = 0
	max_index = -1
	sum_verses = 0
	discard = False
	for index in range(len(verses) - 1):
		if verses[index] > max_verse:
			max_verse = verses[index]
			max_index = index
		if sum_verses + verses[index] > s:
			temp_sum = sum_verses - max_verse + verses[index] + verses[index + 1]
			if temp_sum <= s:
				discard = True
			break
		else:
			sum_verses += verses[index]
	if discard:
		print(max_index + 1)
	else:
		print('0')


t = int(input())
for _ in range(t):
	s = input().split()
	n = int(s[0])
	s = int(s[1])
	a = input().split()
	a = [int(x) for x in a]
	total = sum(a)
	pos = -1
	summ = 0
	maxx = a[0]
	maxindex = 0
	flag = 0
	for i in range(n):
		if summ > s:
			break
		summ = summ + a[i]
		if i == n - 1:
			flag = 1
		if maxx < a[i]:
			maxx = a[i]
			maxindex = i
	if flag == 1:
		print(0)
	else:
		print(maxindex + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	poem = list(map(int, input().split()))
	if n == 1 or sum(poem) <= s:
		print(0)
		continue
	start = 0
	t = -1
	a = 0
	res1 = 0
	res2 = 0
	for i in range(n):
		start += poem[i]
		if poem[i] > t:
			t = poem[i]
			a = i
		if start > s:
			break
		res1 += 1
	print(a + 1)


def solve():
	t = int(input())
	for _ in range(t):
		s1 = input()
		(n, s) = map(int, s1.split())
		s2 = input()
		nums = list(map(int, s2.split()))
		(summ, i) = (0, 0)
		(mxm, mxm_idx) = (-1, -1)
		while summ <= s and i < n:
			summ += nums[i]
			if nums[i] > mxm:
				mxm = nums[i]
				mxm_idx = i
			i += 1
		if summ <= s:
			print(0)
			continue
		print(mxm_idx + 1)
solve()


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = [int(v) for v in input().split()]
	if sum(a) > s:
		m = 0
		mi = -1
		c = 0
		for (i, v) in enumerate(a):
			c += v
			if c - m > s and c - v > s:
				break
			if v > m:
				m = v
				mi = i
		print(mi + 1)
	else:
		print(0)


test = eval(input())
numLst = []
vers = []
for i in range(test):
	ver = input()
	nums = input()
	numLst.append(nums)
	vers.append(ver)
for i in range(test):
	lst = numLst[i]
	ver = vers[i]
	nums = lst.split(' ')
	vLst = ver.split(' ')
	(skpd, ski) = (0, 0)
	v = int(vLst[1])
	(j, ctr) = (0, 0)
	while v >= 0 and j < len(nums):
		if int(nums[j]) > skpd:
			if v - skpd >= 0:
				v -= skpd
				ctr = 1
				(skpd, ski) = (int(nums[j]), j + 1)
		else:
			if v - int(nums[j]) < 0:
				break
			v -= int(nums[j])
		j += 1
	if j == len(nums) and v >= 0:
		if v - skpd >= 0:
			ski = 0
	print(ski)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, s) = LI()
		a = LI()
		m = 0
		mi = 0
		t = 0
		for (i, c) in enumerate(a, 1):
			if c > m:
				m = c
				mi = i
			t += c
			if t > s:
				break
		rr.append(IF(sum(a) <= s, 0, mi))
	return JA(rr, '\n')
print(main())


t = int(input())
for i in range(t):
	(n, s) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	prefix = [0] * n
	found = False
	prefix[0] = nums[0]
	for i in range(1, len(nums)):
		prefix[i] = prefix[i - 1]
		prefix[i] += nums[i]
		if prefix[i] > s:
			found = True
			(mind, mel) = (0, 0)
			for j in range(i + 1):
				if nums[j] > mel:
					mel = nums[j]
					mind = j + 1
			print(mind)
			break
	if not found:
		print(0)


def sol():
	(n, s) = map(int, input().split())
	pref = list(map(int, input().split()))
	mx = [pref[0]]
	ind = [0]
	for j in range(1, n):
		if pref[j] > mx[-1]:
			ind.append(j)
		else:
			ind.append(ind[-1])
		mx.append(max(mx[-1], pref[j]))
		pref[j] += pref[j - 1]
	jnd = 0
	for j in range(n):
		if pref[j] <= s:
			jnd = 0
		elif pref[j] - mx[j] <= s:
			jnd = ind[j] + 1
	print(jnd)
for i in range(int(input())):
	sol()


t = int(input())
while t:
	t -= 1
	(n, s) = map(int, input().split())
	(*a,) = map(int, input().split())
	tmp_s = 0
	mx = 0
	_i = -1
	used = False
	for i in range(n):
		tmp_s += a[i]
		if mx < a[i] and (not used):
			mx = a[i]
			_i = i
		if tmp_s > s:
			if not used:
				tmp_s -= mx
				used = True
			else:
				break
	if used:
		print(_i + 1)
	else:
		print(0)


import sys
import math
t = int(input())
while t:
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l[:]) <= x:
		print(0)
	else:
		maxi = l[0]
		ind = 0
		suma = 0
		cnt = 0
		ans = 0
		for i in range(n):
			suma += l[i]
			if l[i] > maxi:
				maxi = l[i]
				ind = i
			if suma > x:
				if suma - maxi <= x:
					suma -= maxi
					ans = ind
					break
				suma += maxi
		print(ans + 1)
	t -= 1


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = tuple(map(int, input().split()))
	ans = 0
	ans1 = 0
	s1 = 0
	for i in range(n):
		if a[i] > a[ans]:
			ans = i
		s1 += a[i]
		if s1 > s:
			break
		ans1 += 1
	ans2 = 0
	s2 = 0
	for i in range(n):
		if i == ans:
			continue
		s2 += a[i]
		if s2 > s:
			break
		ans2 += 1
	if ans1 > ans2:
		print('0')
	else:
		print(ans + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	(*a,) = map(int, input().split())
	sum = 0
	mx = 0
	skip = 0
	for i in range(n):
		if a[mx] < a[i]:
			mx = i
		sum += a[i]
		if sum > s:
			if skip == 0:
				skip = mx + 1
				sum -= a[mx]
			else:
				break
	print(skip)


import sys
input = sys.stdin.readline
from itertools import accumulate
import bisect
t = int(input())
for test in range(t):
	(n, s) = map(int, input().split())
	A = list(map(int, input().split()))
	S = list(accumulate(A))
	if S[-1] <= s:
		print(0)
		continue
	ANS = 0
	MAX = 0
	for i in range(n):
		x = bisect.bisect_right(S, A[i] + s)
		if i >= x:
			continue
		if x > MAX:
			MAX = x
			ANS = i
	print(ANS + 1)


a = int(input())
for i in range(a):
	(n, s) = map(int, input().split())
	z = list(map(int, input().split()))
	pref = [z[0]]
	maxa = [[z[0], 0]]
	ans = 0
	value = 0
	flag = 0
	save = 0
	for i in range(1, len(z)):
		if z[i] > maxa[-1][0]:
			maxa.append([z[i], i])
		else:
			maxa.append(maxa[-1])
	for i in range(len(maxa)):
		if value + z[i] <= s:
			ans += 1
			value += z[i]
		else:
			save = maxa[i][1]
			flag = 1
			break
	if flag == 0:
		print(0)
	else:
		print(save + 1)


def sol(liste, s):
	if sum(liste) <= s:
		return 0
	if sum(liste) > s:
		a = liste[0]
		if liste[0] > s and len(liste) >= 2 and (liste[1] > s):
			return 0
		if liste[0] > s and len(liste) == 1:
			return 0
		i = 1
		while a <= s and i < len(liste):
			a += liste[i]
			i = i + 1
		b = 0
		can = False
		for j in range(0, i):
			if liste[b] < liste[j] and a - liste[j] <= s:
				b = j
		if i < len(liste) and a - liste[b] + liste[i] <= s:
			can = True
		if can:
			return b + 1
		else:
			return 0
t = int(input())
while t > 0:
	t -= 1
	(n, s) = map(int, input().split())
	liste = list(map(int, input().split()))
	print(sol(liste, s))


n = int(input())
for i in ' ' * n:
	(k, s) = map(int, input().split())
	L = list(map(int, input().split()))
	M = [0] * k
	for j in range(k):
		if j == 0:
			M[0] = L[0]
		else:
			M[j] = M[j - 1] + L[j]
	locmac = 0
	for j in range(k):
		if L[j] > locmac:
			locmac = L[j]
		M[j] -= locmac
	M.append(sum(L))
	t = 0
	for j in range(len(M)):
		if M[j] <= s:
			t = j
	if t == len(L):
		print(0)
	else:
		newL = L[:t + 1]
		mxL = max(newL)
		print(newL.index(mxL) + 1)


t = int(input())
for _ in range(t):
	(s, n) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	if sum(a) <= n:
		print(0)
		continue
	re = [0 for _ in range(s)]
	not_re = [0 for _ in range(s)]
	skip = 1
	re[0] = a[0]
	for i in range(1, s):
		if not_re[i - 1] + a[i] > n and re[i - 1] > n:
			break
		if not_re[i - 1] + a[i] > re[i - 1]:
			not_re[i] = re[i - 1]
			skip = i + 1
		else:
			not_re[i] = not_re[i - 1] + a[i]
		re[i] = re[i - 1] + a[i]
	print(skip)


N = int(input())
for _ in range(N):
	(n, s) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	(mx, mxi) = (a[0], 0)
	ss = 0
	for i in range(len(a)):
		ss += a[i]
		if a[i] > mx:
			(mx, mxi) = (a[i], i)
		if ss > s:
			print(mxi + 1)
			break
	else:
		print(0)
		continue


q = int(input())
while q > 0:
	q -= 1
	n = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	smax = 0
	ans = -1
	s = 0
	for (i, x) in enumerate(a):
		s += x
		if smax < x:
			smax = x
			ans = i
		if s > n[1]:
			break
	if s > n[1]:
		print(ans + 1)
	else:
		print(0)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		z = list(map(int, input().split()))
		n = z[0]
		l = z[1]
		x = list(map(int, input().split()))
		cm = 0
		ci = 0
		flag = True
		s = 0
		if sum(x) - max(x) <= l:
			if sum(x) <= l:
				print(0)
			else:
				tmp = max(x)
				for i in range(n):
					if x[i] == tmp:
						print(i + 1)
						break
			continue
		for i in range(n):
			s += x[i]
			if x[i] > cm:
				if s - x[i] > l:
					print(ci)
					flag = False
					break
				cm = x[i]
				ci = i + 1
			if s - cm > l:
				break
		if flag:
			print(ci)
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, s) = ria()
		a = ria()
		c = sum(a)
		z = []
		if c <= s:
			print(0)
		else:
			si = 0
			t = 0
			pt = 0
			for i in range(n):
				t += a[i]
				if a[i] > si:
					if t - a[i] > s:
						break
					si = a[i]
					pt = i
			print(pt + 1)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(N, s) = map(int, input().split())
	A = list(map(int, input().split()))
	cs = [0] * (N + 1)
	cm = [0] * (N + 1)
	cm_idx = [0] * (N + 1)
	for i in range(N):
		cs[i + 1] = cs[i] + A[i]
		if cm[i] < A[i]:
			cm[i + 1] = A[i]
			cm_idx[i + 1] = i + 1
		else:
			cm[i + 1] = cm[i]
			cm_idx[i + 1] = cm_idx[i]
	if cs[-1] <= s:
		print(0)
		continue
	opt = [0] * (N + 1)
	for i in range(1, N + 1):
		opt[i] = cs[i] - cm[i]
	for i in range(1, N + 1):
		if opt[i] > s:
			print(cm_idx[i - 1])
			break
		if i == N:
			print(cm_idx[i])


def fmaxm(array, i):
	j = 0
	maxm = -1
	ind = -1
	while j <= i:
		if array[j] > maxm:
			maxm = array[j]
			ind = j
		j += 1
	return ind + 1
t = int(input())
for x0 in range(t):
	(n, s) = input().split()
	s = int(s)
	array = list(map(int, input().split()))
	cumm = []
	i = 0
	while i < len(array):
		if i == 0:
			cumm.append(array[i])
		else:
			cumm.append(cumm[-1] + array[i])
		i += 1
	i = 0
	while i < len(array):
		if cumm[i] > s:
			break
		i += 1
	if i == len(array):
		print(0)
	else:
		print(fmaxm(array, i))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	max_index = []
	prefix_array = []
	prefix_array.append(a[0])
	max_elem = 0
	max_index.append(0)
	i = 1
	while i < n:
		prefix_array.append(prefix_array[i - 1] + a[i])
		if a[i] > a[max_elem]:
			max_elem = i
		max_index.append(max_elem)
		i += 1
	skipped = False
	skip = -1
	for i in range(n):
		if prefix_array[i] > k:
			if not skipped:
				skip = max_index[i]
				skipped = True
			elif prefix_array[i] - a[skip] > k:
				break
	print(skip + 1)


kl = int(input())
for l in range(kl):
	(n, t) = [int(i) for i in input().split()]
	mx = 0
	mxs = 0
	nrs = 0
	sc = 0
	nr = 0
	sum = 0
	pr = 1
	for i in input().split():
		i = int(i)
		sc += 1
		sum += i
		if mx < i:
			mxs = mx
			mx = i
			nrs = nr
			nr = sc
		if sum > t and sum - mx <= t:
			pr = 0
			print(nr)
			break
	if pr:
		if sum <= t:
			print(0)
		else:
			print(nr)


q = int(input())
for z in range(q):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	if sum(arr) <= s:
		print(0)
		continue
	a = 0
	mx = -1
	flag = False
	for i in range(n):
		a += arr[i]
		mx = max(mx, arr[i])
		if a > s:
			ind = arr.index(mx)
			if i == n - 1:
				print(n)
				flag = True
			elif arr[i + 1] >= mx:
				print(i + 1 + 1)
				flag = True
				break
			else:
				print(ind + 1)
				flag = True
				break
	if not flag:
		print(0)


tc = int(input())
for t in range(tc):
	(n, s) = map(int, input().split())
	ar = list(map(int, input().split()))
	sm = sum(ar)
	if sm <= s:
		print('0')
		continue
	(temp, sm, ans) = (ar[0], 0, 1)
	for i in range(1, n):
		if ar[i] < temp:
			if sm + ar[i] <= s:
				sm += ar[i]
			else:
				break
		elif sm + temp <= s:
			sm += temp
			temp = ar[i]
			ans = i + 1
		else:
			break
	print(ans)


t = int(input())
for i in range(t):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	(mx, sm, mxi) = (0, 0, 0)
	k = True
	for ii in range(len(a)):
		i = a[ii]
		sm += i
		if i > mx:
			(mx, mxi) = (i, ii)
		if sm > s:
			break
	else:
		k = False
	if k == False:
		print(0)
	else:
		sm -= mx
		ad = 0
		for ij in range(ii, len(a)):
			j = a[ij]
			ad += 1
			sm += i
			if sm > s:
				break
		if ad == 0:
			print(0)
		else:
			print(mxi + 1)


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
inf = float('inf')

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

def LI():
	return list(map(int, sys.stdin.readline().split()))
q = I()
for _ in range(q):
	(n, s) = LI()
	a = LI()
	b = list(accumulate(a))
	tmp = a[0]
	idx = 1
	a[0] = 1
	for i in range(1, n):
		if tmp < a[i]:
			tmp = a[i]
			a[i] = i + 1
			idx = i + 1
		else:
			a[i] = idx
	for i in range(n):
		if b[i] > s:
			if i + 1 < n:
				if a[i + 1] > a[i]:
					print(0)
				else:
					print(a[i])
			else:
				print(a[i])
			break
	else:
		print(0)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	L = list(map(int, input().split()))
	ps = [0] * n
	ps[0] = L[0]
	for i in range(1, n):
		ps[i] = ps[i - 1] + L[i]
	ps2 = []
	grreater = [0] * n
	t = 0
	for i in range(n):
		if L[i] > t:
			t = L[i]
		grreater[i] = ps[i] - t
	if ps[n - 1] <= k:
		print('0')
	else:
		for i in range(n):
			if grreater[i] > k:
				n = i
				break
		t = 0
		for i in range(n):
			if t < L[i]:
				t = L[i]
		for i in range(n):
			if L[i] == t:
				print(i + 1)
				break


import sys
testcases = int(input())
answerlist = []
for k in range(testcases):
	(numbers, seconds) = map(int, sys.stdin.readline().split())
	numberlist = list(map(int, sys.stdin.readline().split()))
	greatest = 0
	greatestindex = 0
	adjustedsecondscounter = seconds
	countervar = 0
	runningsum = 0
	while adjustedsecondscounter > 0 and countervar <= len(numberlist) - 1:
		if numberlist[countervar] > greatest and adjustedsecondscounter - greatest >= 0:
			adjustedsecondscounter += -greatest
			greatest = numberlist[countervar]
			greatestindex = countervar
		elif numberlist[countervar] < adjustedsecondscounter:
			adjustedsecondscounter += -numberlist[countervar]
		elif numberlist[countervar] > adjustedsecondscounter and numberlist[countervar] < greatest:
			countervar = numbers
		if countervar <= numbers - 1:
			runningsum += numberlist[countervar]
		countervar += 1
	if runningsum <= seconds:
		answerlist.append(str(0))
	else:
		answerlist.append(str(greatestindex + 1))
for l in answerlist:
	sys.stdout.write('\n' + l)


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import accumulate, combinations, permutations, combinations_with_replacement, product
from collections import *
import timeit, time
M = 10 ** 9 + 7
from heapq import *
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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')

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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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 inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchcount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] == key:
			return mid
		if arr[mid] <= key:
			left = mid + 1
		else:
			right = mid - 1
	return -1

def ternarysearch(arr, n, key):
	(l, r) = (0, n - 1)
	while l <= r:
		mid = (-l + r) // 3 + l
		mid2 = mid + (-l + r) // 3
		if arr[mid] == key:
			return mid
		if arr[mid2] == key:
			return mid2
		if arr[mid] > key:
			r = mid - 1
		elif arr[mid2] < key:
			l = mid2 + 1
		else:
			l = mid + 1
			r = mid2 - 1
	return -1

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def factorization(n, l):
	c = n
	if prime(n) == True:
		l.append(n)
		return l
	for i in range(2, c):
		if n == 1:
			break
		while n % i == 0:
			l.append(i)
			n = n // i
	return l

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	sub = []
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] < A[i]:
				sub.append(l[k])
		l[i] = 1 + max(sub, default=0)
	return max(l, default=0)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def toString(List):
	return ''.join(List)

def permute(a, l, r, p):
	if l == r:
		p.append(toString(a))
	else:
		for i in range(l, r + 1):
			(a[l], a[i]) = (a[i], a[l])
			permute(a, l + 1, r)
			(a[l], a[i]) = (a[i], a[l])

def squareRoot(number, precision):
	start = 0
	(end, ans) = (number, 1)
	while start <= end:
		mid = int((start + end) / 2)
		if mid * mid == number:
			ans = mid
			break
		if mid * mid < number:
			start = mid + 1
		else:
			end = mid - 1
	increment = 0.1
	for i in range(0, precision):
		while ans * ans <= number:
			ans += increment
		ans = ans - increment
		increment = increment / 10
	return ans

def countRectangles(l, w):
	squareSide = math.gcd(l, w)
	return int(l * w / (squareSide * squareSide))

def count_same_digit(L, R):
	tmp = 0
	ans = 0
	n = int(math.log10(R) + 1)
	for i in range(0, n):
		tmp = tmp * 10 + 1
		for j in range(1, 10):
			if L <= tmp * j and tmp * j <= R:
				ans += 1
	return ans

def findCrossOver(arr, low, high, x):
	if arr[high] <= x:
		return high
	if arr[low] > x:
		return low
	mid = (low + high) // 2
	if arr[mid] <= x and arr[mid + 1] > x:
		return mid
	if arr[mid] < x:
		return findCrossOver(arr, mid + 1, high, x)
	return findCrossOver(arr, low, mid - 1, x)

def Kclosest(arr, x, k, n, ans):
	l = findCrossOver(arr, 0, n - 1, x)
	r = l + 1
	count = 0
	if arr[l] == x:
		l -= 1
	while l >= 0 and r < n and (count < k):
		if x - arr[l] < arr[r] - x:
			ans.append(arr[l])
			l -= 1
		else:
			ans.append(arr[r])
			r += 1
		count += 1
	while count < k and l >= 0:
		ans.append(arr[l])
		l -= 1
		count += 1
	while count < k and r < n:
		ans.append(arr[r])
		r += 1
		count += 1
	return ans

def prime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True

def calcSum(arr, n, k):
	l = []
	sum = 0
	for i in range(k):
		sum += arr[i]
	l.append(sum)
	for i in range(k, n):
		sum = sum - arr[i - k] + arr[i]
		l.append(sum)
	return l

def dfs(root, nodeVal, nodeConnection, visited):
	leftVal = nodeVal[root][0]
	rightVal = nodeVal[root][1]
	solution = []
	if nodeConnection[root]:
		visited.add(root)
		for i in nodeConnection[root]:
			if i not in visited:
				solution.append(dfs(i, nodeVal, nodeConnection, visited))
		leftMax = 0
		rightMax = 0
		for i in solution:
			(l, r) = i
			leftMax += max(abs(leftVal - l[0]) + l[1], abs(leftVal - r[0]) + r[1])
			rightMax += max(abs(rightVal - l[0]) + l[1], abs(rightVal - r[0]) + r[1])
		return ((leftVal, leftMax), (rightVal, rightMax))
	else:
		return ((leftVal, 0), (rightVal, 0))

def luckynumber(x, n, a):
	if x > 0:
		a.append(x)
	if x > 10 ** 9:
		return a
	elif x < 1000000000000.0:
		luckynumber(x * 10 + 4, n, a)
		luckynumber(x * 10 + 7, n, a)

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

def main():
	for _ in range(inpu()):
		(n, s) = sep()
		arr = lis()
		i = 0
		cnt = 0
		ans = 0
		p = 0
		while i < n:
			if arr[i] > arr[ans]:
				ans = i
			p += arr[i]
			if p > s:
				break
			i += 1
		if p <= s:
			print(0)
		else:
			print(ans + 1)
main()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		(n, s) = mi()
		a = li()
		m = 0
		t = 0
		f = 0
		if sum(a) <= s:
			print(0)
			continue
		pos = 0
		for i in range(n):
			t += a[i]
			if t > s and f == 0:
				if a[i] > m:
					f = 1
					print(i + 1)
					break
				else:
					t -= m
					f = 1
					print(pos + 1)
					break
				f = 1
			if a[i] > m:
				m = a[i]
				pos = i
		if f == 0:
			print(0)
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')

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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import *
import os, sys
from bisect import *
from io import BytesIO
sys.setrecursionlimit(10 ** 9)
for i in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= t:
		print(0)
	else:
		s = 0
		ind = 0
		for i in range(n):
			if s + a[i] > t:
				ind = i
				break
			s += a[i]
		mx = a[0]
		im = 0
		for i in range(ind + 1):
			if a[i] > mx:
				mx = a[i]
				im = i
		print(im + 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		(pre, premax) = ([a[0]], [[a[0], 0]])
		for i in range(1, n):
			pre.append(pre[-1] + a[i])
			if a[i] > premax[-1][0]:
				premax.append([a[i], i])
			else:
				premax.append(premax[-1])
		ind = 0
		while ind < n and pre[ind] - premax[ind][0] <= s:
			ind += 1
		print(premax[ind - 1][1] + 1)


t = int(input())
for f in range(t):
	(n, s) = map(int, input().split())
	a = [int(s) for s in input().split()]
	if n == 1 or sum(a) <= s:
		print(0)
	else:
		summ = 0
		i = 0
		while True:
			summ += a[i]
			if summ <= s:
				i += 1
			else:
				break
		print(a.index(max(a[0:i + 1])) + 1)


T = int(input())
for i in range(T):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ct1 = 0
	pos = 0
	if sum(a) <= s:
		ct1 = len(a)
	s1 = 0
	for j in range(n):
		if s1 + a[j] <= s:
			s1 = s1 + a[j]
		else:
			break
	if j == 0:
		pos = 0
	else:
		b = a[:j + 1]
		m = b[0]
		pos = 0
		for i in range(len(b)):
			if b[i] > m:
				m = b[i]
				pos = i
	if ct1 == len(a):
		print(0)
	else:
		print(pos + 1)


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	(n, s) = map(int, I().split())
	a = list(map(int, I().split()))
	if sum(a) <= s:
		ans += '0\n'
	else:
		total = 0
		i = 0
		while total <= s:
			total += a[i]
			i += 1
		ans += str(a.index(max(a[:i])) + 1) + '\n'
print(ans)


import sys
from itertools import accumulate
q = int(input())
for _ in range(q):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	sums = list(accumulate(a))
	i = 0
	while i < n and s >= sums[i]:
		i += 1
	if i == n:
		print(0)
		continue
	sub = sorted(a[:i + 1])
	max_element = sub[-1]
	i = 0
	while a[i] != max_element:
		i += 1
	print(i + 1)


for _ in ' ' * int(input()):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	(se, i, m, j) = (0, 0, 0, 0)
	while i < n and s >= a[i] + se:
		if a[i] > m:
			m = a[i]
			j = i
		se += a[i]
		i += 1
	r = 0
	k = 0
	se1 = se
	i1 = i + 1
	r1 = 0
	p = i + 1
	se -= m
	while i < n and s >= se + a[i]:
		r += 1
		se += a[i]
		i += 1
	while i1 < n and s >= se1 + a[i1]:
		r1 += 1
		se1 += a[i1]
		i1 += 1
	if r > r1:
		print(j + 1)
	elif r1:
		print(p)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ps = 0
	j = 0
	mn = 0
	mi = 0
	while ps <= s and j < n:
		x = a[j]
		ps = ps + x
		if x > mn:
			mn = x
			mi = j
		j = j + 1
	if sum(a) <= s:
		print(0)
	else:
		print(mi + 1)


for _ in [0] * int(input()):
	(n, s) = map(int, input().split())
	verse = list(map(int, input().split()))
	sums = 0
	fg = False
	max = 0
	for i in range(n):
		if verse[i] > verse[max]:
			max = i
		sums += verse[i]
		if sums > s:
			fg = True
			break
	if fg:
		print(max + 1)
	else:
		print(0)


for i in range(int(input())):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	count = 0
	flag = 0
	for j in range(n):
		count += arr[j]
		if count > s:
			flag = 1
			break
	if flag == 1:
		print(arr.index(max(arr[:j + 1])) + 1)
	else:
		print(0)


import sys, math
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	(n, s) = invr()
	a = inlt()
	c = 0
	for i in range(len(a)):
		c = c + a[i]
		if c > s:
			break
	q = a.index(max(a[:i + 1])) + 1
	if sum(a) <= s:
		q = 0
	print(q)


t = int(input())
while t:
	read = input().split()
	n = int(read[0])
	s = int(read[1])
	read = input().split()
	j = 0
	maxa = 0
	sum = 0
	tag = 0
	for i in range(len(read)):
		tmp = int(read[i])
		if sum <= s:
			sum += tmp
			j += 1
			if tmp > maxa:
				maxa = tmp
				tag = i + 1
	if sum <= s and j >= len(read):
		print(0)
		t -= 1
		continue
	print(tag)
	t -= 1


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	t = map(int, input().split())
	t = list(t)
	MAX = 0
	SUM = 0
	for (i, x) in enumerate(t):
		SUM += x
		if SUM - max(MAX, x) > s:
			break
		if MAX <= x:
			MAX = x
			ans = i + 1
	if sum(t) <= s:
		print(0)
	else:
		print(ans)


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		if a[ans] < a[i]:
			ans = i
		s -= a[i]
		if s < 0:
			break
	if s >= 0:
		ans = -1
	print(ans + 1)
	t -= 1


import bisect
t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	s = int(l[1])
	l = input().split()
	li = [int(i) for i in l]
	sumi = [0 for i in range(n)]
	sumnow = 0
	for i in range(n):
		sumnow += li[i]
		sumi[i] = sumnow
	if sumi[-1] <= s:
		print(0)
	else:
		curr = bisect.bisect(sumi, s)
		if curr == 0:
			curr2 = bisect.bisect(sumi, s + li[0]) - 1
		else:
			curr2 = bisect.bisect(sumi, s + max(li[0:curr + 1])) - 1
		if curr > curr2:
			print(0)
		else:
			maxa = 0
			ans = 0
			for i in range(curr + 1):
				if li[i] > maxa:
					maxa = li[i]
					ans = i
			print(ans + 1)


t = int(input())
from collections import defaultdict
for i in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	a = 1
	c = 0
	b = l[0]
	ans = 0
	d = defaultdict(int)
	for j in range(n):
		c += l[j]
		if l[j] >= b:
			a = j + 1
		b = max(b, l[j])
		if c - b <= s:
			d[j + 1] = a
			ans = max(ans, j + 1)
		else:
			break
	if sum(l) <= s:
		print(0)
	else:
		print(d[ans])


from bisect import *
t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	ans = 0
	cur = 0
	l = list(map(int, input().split(' ')))
	a = []
	flag = 0
	for i in range(n):
		cur += l[i]
		a.append(cur)
	s = bisect_right(a, k)
	if s == n:
		print(0)
		flag = 1
	else:
		try:
			t = l.index(max(l[:s + 1]))
			print(t + 1)
		except ValueError:
			print(0)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	mx_i = 0
	mx = 0
	count = 0
	cum = 0
	flag = 0
	for i in range(n):
		if a[i] > mx:
			mx = a[i]
			mx_i = i
		cum += a[i]
		if cum > s:
			print(mx_i + 1)
			flag = 1
			break
	if flag:
		continue
	print(0)


for i in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if s >= sum(l):
		print(0)
	else:
		summ = 0
		su = 0
		ans = 0
		maxx = 0
		finish = 0
		for i in range(n):
			if l[i] > maxx:
				max_index = i
				maxx = l[i]
			if su + l[i] <= s:
				su += l[i]
				ans += 1
			else:
				finish = i
				break
		z = s - su + maxx
		new_sum = 0
		new_ans = 0
		for i in range(finish, n):
			if new_sum + l[i] <= z:
				new_sum += l[i]
				new_ans += 1
			else:
				break
		if ans < ans + new_ans - 1:
			print(max_index + 1)
		else:
			print(0)


n = int(input())
for _ in range(n):
	(a, k) = map(int, input().split())
	l = list(map(int, input().split()))
	s = 0
	for i in range(a):
		s += l[i]
		if s > k:
			l = l[:i + 1]
			break
	if s > k:
		p = l.index(max(l))
		print(p + 1)
	else:
		print('0')


for _ in range(int(input())):
	(n, s) = map(int, input().split(' '))
	data = list(map(int, input().split(' ')))
	no_deleting_sum = s
	deleting_sum = s
	no_deleting = 0
	deleting = 0
	summary = 0
	max_value = 0
	index = -1
	result = -1
	for i in range(n):
		summary += data[i]
		if max_value < data[i]:
			max_value = data[i]
			index = i + 1
		if no_deleting_sum >= summary:
			no_deleting = i + 1
		if deleting_sum >= summary - max_value:
			deleting = i
			result = index
	if no_deleting > deleting:
		print('0')
	else:
		print(result)


for i in range(int(input())):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	sum1 = 0
	sum2 = 0
	m = a[0]
	mi = 0
	p = 0
	for i in range(0, n):
		sum1 += a[i]
		if m < a[i]:
			m = a[i]
			mi = i
		if sum1 > s:
			p = 1
			print(mi + 1)
			break
	if p == 0:
		print(0)


for q in range(int(input())):
	(n, s) = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	if sum(d) <= s:
		print(0)
		continue
	mx = d[0]
	mxi = 0
	sm = 0
	ans = 1
	for i in range(n):
		sm += d[i]
		if d[i] > mx:
			mx = d[i]
			mxi = i
		if sm - mx <= s:
			ans = mxi + 1
		else:
			break
	print(ans)


def search(arr, low, high, target):
	while low < high:
		mid = low + (high - low + 1) // 2
		val = arr[mid]
		if val > target:
			high = mid - 1
		else:
			low = mid
	return low
for _ in range(int(input())):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	csum = [a[0]]
	for i in range(1, n):
		csum.append(csum[-1] + a[i])
	ans = 0
	count = 0
	if s >= csum[-1]:
		print(0)
		continue
	else:
		ans = -1
		for i in range(n):
			pastsum = 0
			if i > 0:
				pastsum = csum[i - 1]
			curans = search(csum, i + 1, n - 1, s + a[i])
			if pastsum <= s and curans > count:
				ans = max(ans, i + 1)
				count = curans
		print(ans)


from sys import stdin

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, s) = minput()
	a = linput()
	if sum(a) <= s:
		print(0)
	else:
		(x, mx) = (0, 0)
		tot = 0
		for i in range(n):
			tot += a[i]
			if a[i] > mx:
				mx = a[i]
				x = i + 1
			if tot > s:
				break
		print(x)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	v = list(map(int, input().split()))
	if sum(v) <= s:
		print(0)
	else:
		t = 0
		for i in range(n):
			t += v[i]
			if t > s:
				end = i
				break
		m = v.index(max(v[:end + 1]))
		print(m + 1)


import time
from math import sqrt

def a_gte_b(a, b):
	for (i, val) in enumerate(a):
		if b[i] > val:
			return False
	return True
LOCAL = False
start_time = None
if LOCAL:
	start_time = time.time()
n = int(input())
while n > 0:
	n -= 1
	(q, s) = list(map(lambda x: int(x), input().split(' ')))
	a = list(map(lambda x: int(x), input().split(' ')))
	cnt = 0
	secs = 0
	highest_i = -1
	highest_num = -1
	for (jum, i) in enumerate(a):
		if i > highest_num:
			highest_num = i
			highest_i = jum
		if secs + i <= s:
			secs += i
			cnt += 1
		else:
			break
	if cnt == q:
		print(0)
	else:
		sec_cnt = 0
		secs = 0
		passed = False
		for i in a:
			if i == highest_num and (not passed):
				passed = True
				continue
			if secs + i <= s:
				secs += i
				sec_cnt += 1
			else:
				break
		print(highest_i + 1)
if LOCAL:
	print('--- %s seconds ---' % (time.time() - start_time))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	x = [int(q) for q in input().split()]
	j = 0
	for i in range(a):
		if x[i] > x[j]:
			j = i
		b -= x[i]
		if b < 0:
			break
	if b >= 0:
		j = -1
	print(j + 1)


def solve(lst, s):
	if sum(lst) <= s:
		return 0
	else:
		count = 0
		t = 0
		for i in range(len(lst)):
			count += lst[i]
			if count > s:
				t = i + 1
				break
		newl = lst[:min(t, len(lst))]
		return lst.index(max(newl)) + 1
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	lst = list(map(int, input().split()))
	print(solve(lst, s))


import sys
t = int(sys.stdin.readline().rstrip())

def main():
	for _ in range(t):
		(n, s) = map(int, sys.stdin.readline().split())
		(*a,) = map(int, sys.stdin.readline().split())
		res = 0
		ma = 0
		for i in range(n):
			cur = a[i]
			if cur > ma:
				ma = cur
				max_ind = i + 1
			if res + cur > s:
				yield max_ind
				break
			res += cur
		else:
			yield 0
ans = main()
print(*ans, sep='\n')


from sys import stdin
from collections import deque
t = int(stdin.readline().strip())

def solve(a, s):
	acc = 0
	left_sums = []
	for el in a:
		acc += el
		left_sums.append(acc)

	def find(left_index, shift, amount):
		right_index = len(a) - 1
		found_index = None
		while left_index <= right_index:
			mid_index = (left_index + right_index) // 2
			if left_sums[mid_index] - shift <= amount:
				found_index = mid_index
				left_index = mid_index + 1
			else:
				right_index = mid_index - 1
		return found_index
	found_max = find(0, 0, s)
	if found_max is None:
		found_max = 0
	delete_index = 0
	for index in range(1, len(a)):
		amount = s - left_sums[index - 1] + a[index - 1]
		shift = left_sums[index - 1]
		if amount <= 0:
			break
		right_index = find(index, shift, amount)
		if right_index is not None:
			if right_index > found_max:
				found_max = right_index - 1
				delete_index = index
	return delete_index
for _ in range(t):
	(n, s) = [int(i) for i in stdin.readline().strip().split()]
	a = [int(i) for i in stdin.readline().strip().split()]
	if sum(a) <= s:
		print(0)
	else:
		print(solve(a, s))


T = int(input())
for _ in range(T):
	(N, S) = map(int, input().split())
	A = [int(a) for a in input().split()]
	if S >= sum(A):
		print(0)
	else:
		ma = 0
		mai = -1
		s = 0
		for i in range(N):
			s += A[i]
			if A[i] > ma:
				ma = A[i]
				mai = i + 1
			if s > S:
				print(mai)
				break


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	it = list(map(int, input().split()))
	ma = 0
	ind = 0
	tot = 0
	ans = 0
	ma_ind = 0
	for i in range(n):
		tot += it[i]
		if tot <= s:
			if i + 1 > ans:
				ind = 0
			ans = max(ans, i + 1)
		elif tot - ma <= s:
			if i > ans:
				ind = ma_ind
			ans = max(ans, i)
		if it[i] > ma:
			ma_ind = i + 1
		ma = max(ma, it[i])
	print(ind)


t = int(input())
for _ in range(t):
	(n, s) = [int(i) for i in input().split()]
	parts = [int(i) for i in input().split()]
	i = 0
	t = 0
	max_skip = -1
	while i < n:
		t += parts[i]
		if t > s:
			max_skip = i
			break
		i += 1
	if max_skip == -1 or max_skip == n - 1:
		print(0)
	elif max_skip == 0:
		print(1)
	else:
		to_skip = parts.index(max(parts[:max_skip + 1]))
		if to_skip == max_skip:
			a = 1
		else:
			a = 0
		if sum(parts[:max_skip + a]) - parts[to_skip] + parts[max_skip + a] > s:
			print(0)
		else:
			print(to_skip + 1)


testcases = int(input())
for k in range(testcases):
	(numbers, seconds) = map(int, input().split())
	numberlist = list(map(int, input().split()))
	greatest = 0
	greatestindex = 0
	adjustedsecondscounter = seconds
	countervar = 0
	runningsum = 0
	while adjustedsecondscounter > 0 and countervar <= len(numberlist) - 1:
		if numberlist[countervar] > greatest and adjustedsecondscounter - greatest >= 0:
			adjustedsecondscounter += -greatest
			greatest = numberlist[countervar]
			greatestindex = countervar
		elif numberlist[countervar] < adjustedsecondscounter:
			adjustedsecondscounter += -numberlist[countervar]
		elif numberlist[countervar] > adjustedsecondscounter and numberlist[countervar] < greatest:
			countervar = numbers
		if countervar <= numbers - 1:
			runningsum += numberlist[countervar]
		countervar += 1
	if runningsum <= seconds:
		print(0)
	else:
		print(greatestindex + 1)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ll = list(map(int, input().split()))
	ss = sum(ll)
	new = 0
	other = -1
	if ss <= m:
		print('0')
	else:
		ss = 0
		for i in range(n):
			ss += ll[i]
			if ll[i] > new:
				new = ll[i]
				other = i
			if ss > m:
				break
		print(other + 1)


import sys, math
input = lambda : sys.stdin.readline().rstrip()

def ch(m, c):
	ans = 0
	for i in m:
		if i <= c:
			c -= i
			ans += 1
		else:
			return ans
	return ans
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	ma = 0
	for i in range(n):
		if a[ma] < a[i]:
			ma = i
		s -= a[i]
		if s < 0:
			break
	if s >= 0:
		print(0)
	else:
		print(ma + 1)


cas = int(input())
for ccccc in range(cas):
	(n, s) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [0 for i in range(n)]
	b[0] = a[0]
	for i in range(n - 1):
		b[i + 1] = b[i] + a[i + 1]
	if sum(a) <= s:
		print(0)
	elif n == 1:
		print(0)
	elif n == 2:
		if a[1] <= s:
			print(1)
		else:
			print(2)
	else:
		ma = 0
		maind = 0
		for i in range(n):
			if ma < a[i] and b[i] - a[i] <= s:
				ma = a[i]
				maind = i + 1
			if b[i] - ma > s:
				break
		print(maind)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	mx = 0
	count = -1
	pos = -1
	ar = [int(x) for x in input().split()]
	for j in range(n):
		s = s - ar[j]
		if mx < max(ar[j], mx):
			mx = max(ar[j], mx)
			pos = j
		if s < 0 and ar[j] < mx:
			count = pos
			break
	print(count + 1)


for i in range(int(input())):
	(n, s) = map(int, input().split())
	lst = list(map(int, input().split()))
	(ma, ind, su, a, b) = (0, 0, 0, n - 1, n - 1)
	for j in range(n):
		if ma != max(ma, lst[j]):
			ma = max(ma, lst[j])
			ind = j
		su += lst[j]
		if su > s:
			b = j
			break
	su1 = -ma
	for k in range(n):
		su1 += lst[k]
		if su1 > s:
			a = k - 1
			break
	if a > b:
		print(ind + 1)
	else:
		print(0)


for tt in range(int(input())):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	if n == 1 or sum(arr) <= s:
		print('0')
	else:
		sm = 0
		ans = []
		f = True
		for i in arr:
			if i + sm > s:
				ans.append(i)
				f = False
				break
			else:
				sm += i
				ans.append(i)
		if f:
			print('0')
		else:
			print(ans.index(max(ans)) + 1)


t = int(input())
for test in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = l
	cnt = []
	c = 0
	q = 0
	sum1 = 0
	sum2 = 0
	if sum(l) <= s:
		print(0)
	else:
		for i in range(n):
			sum1 = sum1 + l[i]
			c = c + 1
			if sum1 > s:
				break
		maxi = max(l[0:c])
		ans = l.index(maxi)
		l.remove(maxi)
		for i in range(n - 1):
			sum2 = sum2 + l1[i]
			q = q + 1
			if sum2 > s:
				break
		if n - 1 == q:
			print(ans + 1)
		elif c > q:
			print(0)
		else:
			print(ans + 1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	mx = arr[0]
	ind = 1
	sm = arr[0]
	f = 0
	for i in range(1, a):
		if arr[i] > mx:
			mx = arr[i]
			ind = i + 1
		if arr[i] + sm > b:
			f = 1
			break
		sm += arr[i]
	if f == 0:
		print(0)
	else:
		print(ind)


n = int(input().strip())
results = []
for i in range(n):
	(n, s) = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	if n == 1:
		if arr[0] > s:
			result = 1
		else:
			result = 0
	else:
		left_max_idx = 0
		left_max = arr[0]
		left_sum = arr[0]
		cursor = 1
		while cursor < len(arr):
			if arr[cursor] > left_max:
				if left_sum <= s:
					left_max = arr[cursor]
					left_max_idx = cursor
					left_sum += arr[cursor]
					cursor += 1
				else:
					break
			elif left_sum - left_max + arr[cursor] <= s:
				left_sum += arr[cursor]
				cursor += 1
			else:
				break
		if left_sum <= s:
			result = 0
		else:
			result = left_max_idx + 1
	results.append(result)
print('\n'.join(map(str, results)))


t = int(input())
for tc in range(t):
	(n, s) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	m = 0
	mi = 0
	i = 0
	while i < n and s >= 0:
		s -= a[i]
		if a[i] > m:
			m = a[i]
			mi = i
		i += 1
	if i == n and s >= 0:
		print(0)
	else:
		print(mi + 1)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = 0
	pre = 0
	m = 0
	ans = []
	idx = -1
	for i in range(n):
		pre += a[i]
		if a[i] > m:
			m = a[i]
			idx = i + 1
		if pre <= s:
			cnt = i + 1
			ans.append([i + 1, 0])
		elif pre - m <= s:
			ans.append([i, idx])
	ans.sort(reverse=True)
	print(ans[0][1])


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = 0
	idex = -1
	take = -1
	remove = -1
	total = 0
	mark = -1
	for i in range(n):
		total += a[i]
		if mx < a[i]:
			mx = a[i]
			idex = i
		cur = total - a[idex]
		if total > s:
			if cur <= s:
				mark = idex
	if mark == -1:
		print(0)
	else:
		print(mark + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split(' '))
	v = [int(x) for x in input().split(' ')]
	t = 0
	f = 0
	for i in range(n):
		if t + v[i] <= s:
			t += v[i]
		else:
			f = 1
			break
	if f == 1:
		print(v.index(max(v[:i + 1])) + 1)
	else:
		print(0)


for i in range(int(input())):
	sum2 = 0
	max = float('-inf')
	(part, s) = list(map(int, input().split()))
	data = list(map(int, input().split()))
	if sum(data) <= s:
		print(0)
		continue
	for i in data:
		sum2 += i
		if max < i:
			max = i
		if sum2 > s:
			print(data.index(max) + 1)
			break


def solve(n, s, a):
	suma = 0
	maxi = -1
	imaxi = -1
	p = -1
	x = 0
	for i in range(0, n):
		if p == -1 and a[i] > maxi:
			maxi = a[i]
			imaxi = i + 1
		if suma + a[i] > s:
			break
		else:
			suma += a[i]
			x += 1
	sumb = 0
	y = 0
	for i in range(n):
		if i == imaxi - 1:
			continue
		elif sumb + a[i] > s:
			break
		else:
			sumb += a[i]
			y += 1
	if y >= x:
		return imaxi
	else:
		return 0

def main():
	for _ in range(int(input())):
		(n, s) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		print(solve(n, s, a))
main()


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		(j, su) = (0, 0)
		while su < s:
			su += a[j]
			j += 1
		print(a.index(max(a[:j + 1])) + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	A = list(map(int, input().split()))
	i = 0
	a_max = 0
	a_max_idx = 0
	a_sum = 0
	while i < n:
		if a_max < A[i]:
			a_max = A[i]
			a_max_idx = i
		a_sum += A[i]
		if a_sum > s:
			break
		i += 1
	next_cnt = 1
	for j in range(1, 2):
		if i + j >= n:
			break
		a_sum += A[i + j]
		next_cnt += 1
	if next_cnt == 2 and a_sum - a_max <= s:
		print(a_max_idx + 1)
	else:
		print(0)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	(*a,) = map(int, input().split())
	if sum(a) <= s:
		print(0)
		continue
	c = idx = mx = 0
	for i in range(n):
		c += a[i]
		if c - max(mx, a[i]) > s:
			print(idx + 1)
			break
		if a[i] > mx:
			(mx, idx) = (a[i], i)
	else:
		print(idx + 1)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	mx = 0
	imx = -1
	ss = 0
	flag = False
	while i < n:
		ss += a[i]
		if a[i] > mx:
			mx = a[i]
		if ss - mx > s:
			break
		if mx == a[i]:
			imx = i
		i += 1
	if ss <= s:
		print(0)
	else:
		print(imx + 1)


import os
import sys
from io import BytesIO, IOBase
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')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	(n, s) = Ri()
	a = Ri()
	summ = 0
	maxx = -1
	pos = -1
	flag = False
	oflag = False
	for i in range(len(a)):
		summ += a[i]
		if a[i] > maxx:
			maxx = a[i]
			pos = i
		if summ > s:
			if not flag:
				flag = True
				summ -= maxx
				break
	if flag:
		print(pos + 1)
	else:
		print(0)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = 0
	s = 0
	t = 0
	ind2 = -1
	for i in range(n):
		if l[i] >= t:
			t = l[i]
			ind1 = i
		if s + l[i] <= m:
			ans += 1
			s += l[i]
		else:
			ind2 = i
			break
	if ind2 == -1:
		print(0)
	else:
		x = s - l[ind1]
		c = 0
		for i in range(ind2, n):
			if x + l[i] <= m:
				x += l[ind2]
				c += 1
			else:
				break
		if c >= 1:
			print(ind1 + 1)
		else:
			print(0)


t = int(input())
for p in range(t):
	(n, s) = map(int, input().split())
	verse = list(map(int, input().split()))
	if sum(verse) <= s:
		print(0)
		continue
	ans = -1
	max_index = 0
	sums = 0
	for i in range(len(verse)):
		sums += verse[i]
		if verse[i] > verse[max_index]:
			max_index = i
		if sums - verse[max_index] <= s:
			ans = max_index
		else:
			break
	print(ans + 1)


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 OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
from itertools import accumulate
from bisect import bisect_right
for _ in range(INI()):
	(n, s) = INL()
	A = INL()
	Q = list(accumulate(A))
	i = bisect_right(Q, s)
	if i == n:
		OPS(0)
	else:
		ans = 0
		m = float('-inf')
		for _ in range(i + 1):
			if A[_] > m:
				ans = _ + 1
				m = A[_]
		OPS(ans)


def abc(k, val, m):
	ans = 0
	i = 0
	j = len(k) - 1
	while i <= j:
		mid = i + (j - i) // 2
		if k[mid] - m <= val:
			ans = mid
			i = mid + 1
		else:
			j = mid - 1
	return ans
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	k = [0]
	for i in l:
		k.append(i + k[-1])
	if k[-1] <= s:
		print(0)
	else:
		ans = -1
		x = -1
		c = 0
		g = 0
		for i in range(n):
			if c > s:
				break
			g += l[i]
			m = abc(k, s - c, g)
			if ans == -1:
				ans = m - 1
				x = i
			elif ans < m - 1:
				ans = m - 1
				x = i
			c += l[i]
		print(x + 1)


import sys, itertools, math
n = int(sys.stdin.readline())
for _ in range(n):
	(n, s) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	N = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	max_n = -1
	max_i = -1
	left = s
	ans = 0
	removed = -1
	ans_removed = 0
	for (i, n) in enumerate(N):
		if n > max_n:
			max_n = n
			max_i = i
		if n <= left:
			ans += 1
			left -= n
		elif max_n >= 0 and removed < 0:
			left += max_n
			ans_removed = ans
			removed = max_i
		else:
			break
	if removed >= 0 and ans >= ans_removed:
		print(removed + 1)
	else:
		print(0)


for ii in range(int(input())):
	b = [int(j) for j in input().split()]
	n = b[0]
	s = b[1]
	a = [int(j) for j in input().split()]
	su = 0
	for i in a:
		su += i
	if su <= s:
		print(0)
	else:
		i = 0
		(l, m) = (0, 0)
		pos_of_max = 0
		flag = False
		while i < len(a):
			if l + a[i] <= s:
				l = l + a[i]
				if max(m, a[i]) == a[i]:
					m = a[i]
					pos_of_max = i
				i += 1
			else:
				break
		left = s - l
		pos_of_max2 = i
		if i + 1 < len(a) and a[i + 1] <= left:
			flag = True
			pos_of_max2 = i
			i = i + 1
			while i < len(a) and l + a[i] <= s:
				l = l + a[i]
				i += 1
		if flag == True:
			x = i - 1
		else:
			x = i
		del a[pos_of_max]
		j = 0
		l = 0
		while j < len(a):
			if l + a[j] <= s:
				l = l + a[j]
				j += 1
			else:
				break
		y = j
		if max(x, y) == x:
			print(pos_of_max2 + 1)
		elif max(x, y) == y:
			print(pos_of_max + 1)


t = int(input())
for _ in range(t):
	(n, s) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	total = 0
	(max_a, max_i) = (0, 1)
	for (i, a) in enumerate(arr):
		total += a
		if total > s:
			if i == 0:
				print(1)
			else:
				print(max_i if max_a > a else i + 1)
			break
		elif a > max_a:
			(max_a, max_i) = (a, i + 1)
	else:
		print(0)


def get_max(l):
	k = len(l)
	maxx = 0
	ind = None
	for i in range(k):
		if maxx < l[i]:
			maxx = l[i]
			ind = i
	return ind + 1
t = int(input())
for ii in range(t):
	(n, T) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	s = [0] * (n + 2)
	for i in range(1, n + 1):
		s[i] = a[i - 1] + s[i - 1]
	s[n + 1] = s[n]
	ind = 0
	for i in range(1, n + 1):
		if s[i] <= T:
			ind = i
	if ind == n:
		print(0)
	else:
		print(get_max(a[:ind + 1]))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, s) = map(int, sys.stdin.readline().split())
	array = list(map(int, sys.stdin.readline().split()))
	somme = 0
	maxi = [-1, -1]
	pre = -1
	i = 0
	stop = False
	while i != n and (not stop):
		somme += array[i]
		if array[i] > maxi[0]:
			pre = maxi[1]
			maxi[1] = i
			maxi[0] = array[i]
		if somme > s:
			print(maxi[1] + 1)
			stop = True
		i += 1
	if not stop:
		print(0)


t = int(input())
for i in range(t):
	ns = list(map(int, input().split()))
	n = ns[0]
	s = ns[1]
	arr = list(map(int, input().split()))
	total = sum(arr)
	if total <= s:
		print('0')
	else:
		g = 0
		index = 0
		for i in range(n):
			g += arr[i]
			if g > s:
				index = i
				break
		maxi = arr[0]
		ans = 0
		for i in range(index + 1):
			if arr[i] > maxi:
				ans = i
				maxi = arr[i]
		print(ans + 1)


def solveOne():
	(n, sec) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= sec:
		return 0
	(ret, got) = (-1, -1)
	psums = [0]
	for dur in a:
		psums.append(psums[-1] + dur)
	for skip in range(n):
		if psums[skip] > sec:
			(left, right) = (-1, skip)
			while left + 1 < right:
				mid = (left + right) // 2
				if psums[mid + 1] > sec:
					right = mid
				else:
					left = mid
			if left + 1 > got:
				(ret, got) = (skip + 1, left + 1)
		else:
			sec -= psums[skip]
			(left, right) = (skip, n)
			while left + 1 < right:
				mid = (left + right) // 2
				if psums[mid + 1] - psums[skip + 1] > sec:
					right = mid
				else:
					left = mid
			if left > got:
				(ret, got) = (skip + 1, left)
			sec += psums[skip]
	return ret
for _ in range(int(input())):
	print(solveOne())


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	(last, curr) = ([l[0], 1], [l[0], 1])
	ans = 0
	for i in range(1, n):
		curr = [l[i], i + 1]
		l[i] = l[i] + l[i - 1]
		if l[i] > s:
			if curr[0] < last[0]:
				ans = last[1]
				break
		last = max(curr, last)
	print(ans)


t = int(input())
for i in range(t):
	(n, s) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.append(1 << 60)
	ans = 0
	best = 0
	r = 0
	for j in range(len(a)):
		if s >= a[j]:
			s -= a[j]
			best += 1
		else:
			ans = j
			r = j
			break
	if r == len(a) - 1:
		print(0)
		continue
	for j in range(len(a)):
		if j >= r:
			break
		if j != 0:
			s -= a[j - 1]
		s += a[j]
		if s >= a[r]:
			s -= a[r]
			ans = j
			r += 1
	print(ans + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	(flag, sum) = (0, 0)
	ls = list(map(int, input().split()))
	for i in range(n):
		sum += ls[i]
		if sum > s:
			flag = 1
			break
	print(ls.index(max(ls[:i + 1])) + 1 if flag else 0)


def largest(arr, n):
	m = arr[0]
	index = 0
	for i in range(1, n + 1):
		if arr[i] > m:
			m = arr[i]
			index = i
	return (m, index)
t = int(input())
while t > 0:
	(n, s) = input().split(' ')
	n = int(n)
	s = int(s)
	index = -1
	summ = 0
	arr = list(map(int, input().split()))
	for i in range(0, n):
		summ += arr[i]
		if summ > s:
			result = largest(arr, i)
			data = result[0]
			index = result[1]
			temp = i
			break
	print(index + 1)
	t = t - 1


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	maxpos = 0
	skip = 0
	add = 0
	deleted = False
	for i in range(n):
		add += a[i]
		if a[i] > a[maxpos]:
			maxpos = i
		if add > s:
			if deleted:
				break
			else:
				add -= a[maxpos]
				deleted = True
				skip = maxpos + 1
	print(skip)


from sys import stdin, stdout

def solve(n, s, a):
	out = stdout.write
	sm = 0
	temp = 0
	mx = a[0]
	for i in range(n):
		sm += a[i]
		if a[i] > mx:
			mx = a[i]
			temp = i
		if sm > s:
			out(str(temp + 1) + '\n')
			return
	out(str(0) + '\n')
	return

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		(n, s) = map(int, inp().split())
		a = list(map(int, inp().split()))
		solve(n, s, a)
main()


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n, s) = I()
	a = I()
	(sum, m) = (0, 0)
	ans = 0
	idx = 0
	for i in range(n):
		sum += a[i]
		if a[i] > m:
			m = a[i]
			idx = i
		debug(sum)
		if sum > s and sum - m <= s:
			ans = idx + 1
		elif sum <= s:
			ans = 0
	print(ans)


from math import *
for x in range(int(input())):
	(n, s) = map(int, input().split())
	verse = list(map(int, input().split()))
	sumy = sum(verse)
	count = []
	soso = 0
	ni = len(verse)
	n = len(verse)
	if sumy > s:
		for i in range(ni):
			soso = soso + verse[i]
			if soso > s:
				soso -= verse[i]
				if i != 0:
					if max(verse[0:i]) >= verse[i]:
						print(verse.index(max(verse[0:i])) + 1)
						break
					else:
						print(i + 1)
						break
				else:
					print(i + 1)
					break
	else:
		print(0)


import bisect
for _ in range(int(input())):
	(n, s) = [int(j) for j in input().split()]
	l = [int(j) for j in input().split()]
	if sum(l) <= s:
		print(0)
	else:
		su = 0
		for i in range(n):
			su += l[i]
			if su > s:
				break
		fin = l[:i + 1]
		print(1 + l.index(max(fin)))


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	nl = list(map(int, input().split()))
	sm = 0
	fg = 0
	for j in range(n):
		sm += nl[j]
		if sm > s:
			fg = 1
			break
	if fg == 1:
		print(nl.index(max(nl[:j + 1])) + 1)
	else:
		print('0')


def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
import math
for i in range(ii()):
	(n, s) = mi()
	a = li()
	c = 0
	p = -1
	ind = 0
	f = 0
	for i in range(n):
		c += a[i]
		if a[i] > p:
			p = a[i]
			ind = i
		if c > s:
			print(ind + 1)
			f = 1
			break
	if f == 0:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(input().split())
	a = [int(i) for i in a]
	sum = 0
	m = -1
	mp = -1
	flag = True
	for i in range(n):
		sum += a[i]
		if a[i] > m:
			m = a[i]
			mp = i
		if sum == s:
			if i + 1 < n:
				if a[i + 1] > m:
					print(0)
					flag = False
					break
				else:
					print(mp + 1)
					flag = False
					break
		elif sum > s:
			if sum - s >= m:
				print(0)
				flag = False
				break
			else:
				print(mp + 1)
				flag = False
				break
	if flag == True:
		print(0)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	a.append(10 ** 10)
	x = s
	i = 0
	m = -1
	max = 0
	while x >= 0:
		x -= a[i]
		if a[i] > max:
			m = i
			max = a[i]
		i += 1
	print((m + 1) % (n + 1))


for t in range(int(input())):
	(n, t) = map(int, input().split())
	ar = list(map(int, input().split()))
	ide = 0
	for i in range(n):
		if ar[i] > ar[ide]:
			ide = i
		t -= ar[i]
		if t < 0:
			break
	if t >= 0:
		ide = -1
	print(ide + 1)


def kkk(a, s):
	tm = 0
	pp = 0
	ss = 0
	ans = 0
	for i in range(len(a)):
		ss = ss + a[i]
		if tm < a[i]:
			tm = a[i]
			pp = i
		if ss - tm <= s:
			ans = pp + 1
	if ss <= s:
		return 0
	return ans
for i in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	print(kkk(a, s))


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(n, s) = map(int, stdin.readline().split())
	verses = list(map(int, stdin.readline().split()))
	(_max, _maxi, _sum) = (0, 0, 0)
	ans = 0
	for (i, v) in enumerate(verses):
		if v > _max:
			(_max, _maxi) = (v, i)
		_sum += v
		if _sum > s:
			ans = _maxi + 1
			break
	stdout.write('{}\n'.format(ans))


import collections
for t in range(int(input())):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		(curr, i, j) = (0, 0, 0)
		for i in range(n):
			if a[i] > a[j]:
				j = i
			s -= a[i]
			if s < 0:
				break
		print(j + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = [int(i) for i in input().split()]
	(summ, flag, c) = (0, 0, 0)
	(z1, z) = (-1, -1)
	for i in range(n):
		summ += a[i]
		if summ > s and flag == 1:
			break
		if summ > s:
			summ -= max(a[:i + 1])
			z = a.index(max(a[:i + 1]))
			a[z] = -1
			flag = 1
			c -= 2
			z1 = c + 1
		c += 1
	if z1 == -1 and z == -1:
		print(0)
	else:
		print(z + 1) if c >= z1 else print(0)


import sys
input = sys.stdin.readline
from bisect import bisect_right
Q = int(input())
Query = []
for _ in range(Q):
	(N, S) = map(int, input().split())
	A = list(map(int, input().split()))
	Query.append((N, S, A))
for (N, S, A) in Query:
	B = [0]
	for (i, a) in enumerate(A):
		B.append(B[-1] + a)
	if B[-1] <= S:
		ans = 0
	else:
		num = -1
		max_p = -1
		for (i, a) in enumerate(A):
			if a > max_p:
				max_p = a
				ind = i + 1
			if B[i + 1] - max_p <= S:
				if i > num:
					num = i
					ans = ind
	print(ans)


for _ in range(int(input())):
	(ans, res) = (0, 0)
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	(sum, flag) = (0, 0)
	for i in range(n):
		sum += a[i]
		if sum > s:
			flag = 1
			break
	if flag:
		print(a.index(max(a[:i + 1])) + 1)
	else:
		print(0)


q = int(input())
for rw in range(q):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	pref = [0] * n
	pref[0] = l[0]
	for i in range(1, n):
		pref[i] = pref[i - 1] + l[i]
	if sum(l) <= s:
		print(0)
	else:
		wyn = 1
		best = 0
		for i in range(n):
			le = i
			p = n - 1
			mid = n - 1
			while True:
				if abs(le - p) == 0:
					break
				mid = (p + le + 1) // 2
				if pref[mid] - l[i] > s:
					p = mid - 1
				else:
					le = mid
			mid = (le + p) // 2
			if pref[mid] - l[i] <= s:
				if mid > best:
					best = mid
					wyn = i + 1
		i = -1
		while i < n - 1:
			if pref[i + 1] <= s:
				i += 1
			else:
				break
		if i >= best:
			print(n)
		else:
			print(wyn)


for iter in range(int(input())):
	num = list(map(int, input().split()))
	mass = list(map(int, input().split()))
	kolvo = num[1]
	summ = 0
	ans = []
	flag = 1
	for i in mass:
		if summ + i > kolvo:
			ans.append(i)
			flag = 0
			break
		else:
			summ += i
			ans.append(i)
	if flag:
		print(0)
	else:
		print(ans.index(max(ans)) + 1)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	n = l[0]
	s = l[1]
	l1 = list(map(int, input().split()))
	sum = 0
	largest = 0
	index = 0
	removed = False
	answered = False
	for num in range(len(l1)):
		sum = sum + l1[num]
		if l1[num] >= largest:
			largest = l1[num]
			index = num
		if sum > s and removed == False:
			sum - largest
			removed = True
			ans = index
		elif sum > s and removed == True:
			print(ans + 1)
			answered = True
			break
	if not answered:
		print(0)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	rhyme = list(map(int, input().split()))
	can = n
	max_part = 0
	max_cost = 0
	for i in range(n):
		s -= rhyme[i]
		if max_cost < rhyme[i]:
			max_cost = rhyme[i]
			max_part = i
		if s < 0:
			can = i
			break
	if can == n:
		print(0)
	else:
		print(max_part + 1)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	sum = 0
	for j in range(n):
		sum += arr[j]
	if sum <= s:
		print(0)
	else:
		k = 0
		maximum = arr[0]
		sum = 0
		new_ans = 0
		for j in range(n):
			if maximum < arr[j]:
				maximum = arr[j]
				k = j
			sum += arr[j]
			if sum - maximum <= s:
				ans = k
				if new_ans < ans:
					new_ans = ans
		print(new_ans + 1)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit
input = sys.stdin.readline

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	(n, s) = mi()
	d = li()
	if sum(d) <= s:
		print(0)
		continue
	cs = m = pos = res = 0
	for i in range(n):
		cs += d[i]
		if d[i] > m:
			m = d[i]
			pos = i
		if cs - m > s:
			break
		res = pos + 1
	print(res)


t = int(input())
while t > 0:
	t -= 1
	s = input()
	v = []
	v = s.split()
	n = int(v[0])
	k = int(v[1])
	s = input()
	v = []
	v = s.split()
	v = [0] + v[:]
	sol = 0
	act = 0
	poz = 0
	ok = 0
	for i in range(1, n + 1):
		v[i] = int(v[i])
		if v[i] > v[poz]:
			poz = i
		if act + v[i] > k:
			break
		act += v[i]
		sol += 1
	sol2 = 0
	act = 0
	for i in range(1, n + 1):
		v[i] = int(v[i])
		if i == poz:
			continue
		if act + v[i] > k:
			break
		sol2 += 1
	if sol >= sol2:
		poz = 0
	print(str(poz))


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	(flag, mx) = (0, 0)
	res = 0
	for i in range(n):
		res += a[i]
		if res > s and flag == 1:
			break
		if a[i] > mx:
			mx = a[i]
			pos = i + 1
		if res > s and flag == 0:
			res -= mx
			flag = 1
	if flag == 0:
		print(0)
	else:
		print(pos)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scan_int = lambda : int(input())
scan_string = lambda : input().rstrip()
read_list = lambda : list(read())
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

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

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(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

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	(n, s) = read()
	a = read_list()
	findmax = {}
	m = 0
	ind = 0
	for i in range(n):
		if a[i] > m:
			m = a[i]
			ind = i
		findmax[i] = ind
	ps = [0]
	for x in a:
		ps.append(ps[-1] + x)
	for i in range(1, len(ps)):
		if ps[i] > s:
			print(findmax[i - 1] + 1)
			return
	print(0)
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')

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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(scan_int()):
	solve()


from itertools import accumulate

def search(a, tr, c, i):
	l = 0
	r = len(a) - 1
	ans = 0
	t = tr
	while r - l >= 0:
		mid = (l + r) // 2
		if mid < i:
			t = tr
		else:
			t = tr + c
		if a[mid] <= t:
			l = mid + 1
			ans = mid
		if a[mid] > t:
			r = mid - 1
	return ans
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		pf = list(accumulate(a))
		m = 0
		mind = 0
		for i in range(n):
			mt = search(pf, s, a[i], i)
			if mt > m:
				mind = i
				m = mt
		print(mind + 1)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, s) = value()
	a = array()
	need_to_skip = [0, 0]
	tot = 0
	curr_max = [0, 0]
	for i in range(n):
		tot += a[i]
		if a[i] > curr_max[0]:
			curr_max[0] = max(a[i], curr_max[0])
			curr_max[1] = i + 1
		if tot > s:
			need_to_skip = curr_max
			break
	print(need_to_skip[1])


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	biggest = 0
	biggestI = -1
	summ = 0
	missed = False
	for (i, ai) in enumerate(a):
		if summ + ai - biggest > s:
			if ai > biggest:
				if summ <= s:
					biggest = ai
					biggestI = i
				else:
					print(biggestI + 1)
					missed = True
					break
			else:
				print(biggestI + 1)
				missed = True
				break
		if biggest < ai:
			biggest = ai
			biggestI = i
		summ = summ + ai
	if not missed and summ <= s:
		print(0)
	elif not missed:
		print(biggestI + 1)


n = int(input())
for x in range(n):
	(a, maxx) = list(map(int, input().split()))
	array = list(map(int, input().split()))
	empty_array = []
	current = 0
	flag = 5
	for it in array:
		if it + current <= maxx:
			empty_array.append(it)
			current += it
		elif empty_array == list():
			if a > 1:
				if array[1] <= maxx:
					print(1)
					flag = 6
					break
				else:
					print(0)
					flag = 6
					break
			else:
				flag = 6
				print(0)
				break
		else:
			jam = empty_array.index(max(empty_array))
			if max(empty_array) > it:
				current -= max(empty_array)
				if current + it > maxx:
					print(0)
					flag = 6
					break
				else:
					print(jam + 1)
					flag = 6
					break
			else:
				print(len(empty_array) + 1)
				flag = 6
				break
	if flag == 5:
		print(0)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	pa = []
	ans = 0
	if sum(l) <= s:
		print(0)
		continue
	for i in range(n - 1):
		if l[i] > l[i + 1]:
			if pa == []:
				pa.append(l[i])
				ans = i + 1
			elif pa[0] < l[i] and s - pa[0] >= 0:
				s -= pa[0]
				pa.pop()
				pa.append(l[i])
				ans = i + 1
				if s == 0:
					break
			elif s >= l[i]:
				s -= l[i]
			else:
				break
		elif pa != []:
			if pa[0] < l[i] and s - pa[0] >= 0:
				s -= pa[0]
				pa.pop()
				pa.append(l[i])
				ans = i + 1
				if s == 0:
					break
			elif s >= l[i]:
				s -= l[i]
			else:
				break
		elif s >= l[i]:
			s -= l[i]
		else:
			break
	i = n - 1
	if pa != []:
		if pa[0] < l[i] and s - pa[0] >= 0:
			s -= pa[0]
			pa.pop()
			pa.append(l[i])
			ans = i + 1
		elif s >= l[i]:
			s -= l[i]
	elif s >= l[i]:
		s -= l[i]
	print(ans)


t = int(input())
for _ in range(t):
	(n, ss) = map(int, input().split())
	s = [int(x) for x in input().split()]
	tot = 0
	ptr = len(s)
	for i in range(0, len(s)):
		tot += s[i]
		if tot > ss:
			ptr = i
			break
	if ptr == len(s):
		print(0)
	else:
		L = [tot - ss]
		for i in range(ptr + 1, len(s)):
			L.append(L[-1] + s[i])
		fnl = -1
		ans = 0
		for i in range(0, ptr + 1):
			low = 0
			high = len(L) - 1
			temp = -1
			while low <= high:
				mid = low + high >> 1
				if L[mid] > s[i]:
					high = mid - 1
				else:
					temp = mid
					low = mid + 1
			if temp > fnl:
				fnl = max(temp, fnl)
				ans = i + 1
		print(ans)


t = int(input())
while t > 0:
	t -= 1
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	su = sum(a)
	ind = -1
	if su <= s:
		print(0)
	else:
		su = 0
		cur_max = 0
		for i in range(n):
			su += a[i]
			if a[i] > cur_max:
				cur_max = a[i]
				ind = i + 1
			if su > s:
				break
		print(ind)


t = int(input())

def solve():
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		return
	c = 0
	m = 0
	mi = 0
	for i in range(n):
		(m, mi) = max((m, mi), (a[i], i))
		if c <= s and c + a[i] > s:
			print(mi + 1)
			return
		c += a[i]
for i in range(t):
	solve()


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	List = [int(x) for x in input().split()]
	Sum = 0
	Index = 0
	Max = 0
	flag = 1
	for i in range(N):
		Sum += List[i]
		if List[i] > Max:
			Index = i + 1
			Max = List[i]
		if Sum > K:
			print(Index)
			flag = 0
			break
	if flag:
		print(0)


T = int(input())
for i in range(T):
	(n, s) = map(int, input().split(' '))
	N = [int(x) for x in input().split()]
	N.append(10000000000)
	N.append(10000000000)
	j = 0
	F = False
	G = -1
	R = -1
	X = 0
	while True:
		if s - N[j] > 0:
			G = max(G, N[j])
			s = s - N[j]
		elif s == N[j]:
			F = True
			G = max(G, N[j])
			break
		else:
			F = False
			R = N[j] - s
			break
		j = j + 1
		if N[j] == 10000000000:
			X = 1
			break
	if X == 1:
		print('0')
	elif F:
		print(N.index(G) + 1) if G >= N[j + 1] + N[j + 2] else print('0')
	elif not F:
		G = max(G, N[j])
		print(N.index(G) + 1) if G >= R + N[j + 1] else print('0')


from sys import stdin
from bisect import bisect_right

def prev(index):
	if index - 1 >= 0:
		return pre[index - 1]
	else:
		return 0
t = int(stdin.readline().strip())
for _ in range(t):
	(n, s) = list(map(int, stdin.readline().split()))
	arr = list(map(int, stdin.readline().split()))
	pre = [arr[0]] * n
	for i in range(1, n):
		pre[i] = pre[i - 1]
		pre[i] += arr[i]
	index = bisect_right(pre, s)
	if index == n:
		print(0)
		continue
	ans = 0
	ans_index = -1
	for i in range(n):
		if prev(i) <= s:
			index2 = bisect_right(pre, s + arr[i], i + 1, n)
			if ans < index2 - 1:
				ans = index2 - 1
				ans_index = i
	print(ans_index + 1)


import math
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
		continue
	ans = 0
	summ = 0
	maxi = 0
	ind = 0
	for i in range(n):
		summ = summ + l[i]
		if summ > s:
			if maxi > l[i]:
				ans = ind + 1
			else:
				ans = i + 1
			break
		if l[i] > maxi:
			ind = i
			maxi = l[i]
	print(ans)


from sys import stdin
for _ in range(int(stdin.readline().rstrip())):
	(n, s) = map(int, stdin.readline().rstrip().split(' '))
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	r = -1
	m = 0
	check = False
	for i in range(0, n):
		if l[i] > m:
			m = l[i]
			r = i
		if l[i] > s:
			s = s + m
			if l[i] > s:
				r = -1
			check = True
			break
		s -= l[i]
	if not check:
		print(0)
	else:
		print(r + 1)


t = int(input())
arr = []
for _ in range(2 * t):
	arr.append(list(map(int, input().strip().split())))
for b in range(t):
	[n, s] = arr[2 * b]
	(mx_num, sm, idx, flag, rm_idx, mx_idx) = (0, 0, 0, 1, -1, 0)
	while idx < n:
		num = arr[2 * b + 1][idx]
		sm += num
		if num > mx_num:
			mx_num = num
			mx_idx = idx
		if sm > s:
			if flag:
				sm -= mx_num
				rm_idx = mx_idx
				flag = 0
			else:
				break
		idx += 1
	print(rm_idx + 1)


t = int(input())
for j in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = 0
	deleted = 0
	for i in range(len(l)):
		if s - l[i] >= 0:
			ans += 1
			s -= l[i]
		else:
			ind = i
			break
	if ans == len(l):
		print(0)
	else:
		max1 = max(l[0:ind + 1])
		for i in range(ind + 1):
			if l[i] == max1:
				print(i + 1)
				break


import math
import copy
t = int(input())
for _ in range(t):
	(n, t) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	id = 0
	for i in range(n):
		if a[i] > a[id]:
			id = i
		t -= a[i]
		if t < 0:
			break
	if t >= 0:
		id = -1
	print(id + 1)


t = int(input())
while t:
	t = t - 1
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	sum = 0
	ans = 0
	max = 0
	for i in range(0, len(arr)):
		sum = sum + arr[i]
		if max < arr[i]:
			max = arr[i]
		if sum <= s and i == len(arr) - 1:
			ans = 0
			break
		elif sum > s:
			ans = arr.index(max) + 1
			break
	print(ans)


t = int(input())
while t > 0:
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	b = a[:]
	for i in range(1, n):
		a[i] = a[i] + a[i - 1]
	if a[-1] <= s:
		print('0')
	else:
		for i in range(n):
			if a[i] > s:
				break
		print(b.index(max(b[:i + 1])) + 1)
	t -= 1


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		continue
	su = i = 0
	while su <= s:
		su += a[i]
		i += 1
	print(a.index(max(a[:i])) + 1)


for x in range(int(input())):
	(n, k) = list(map(int, input().split()))
	m = list(map(int, input().split()))
	s = 0
	i = 0
	ma = 0
	while i < n:
		if m[i] + s <= k:
			s += m[i]
			ma = max(ma, m[i])
			i += 1
		elif m[i] + s > k:
			ma = max(ma, m[i])
			i += 1
			break
		else:
			break
	if i == n:
		print(0)
	elif m[i] > ma:
		print(0)
	else:
		print(m.index(ma) + 1)


x = int(input())
for i in range(x):
	a = input().split(' ')
	n = int(a[0])
	s = int(a[1])
	y = list(map(int, input().split(' ')))
	z = 0
	j = 0
	m = y[0]
	w = 1
	q = 0
	while j < len(y) and z + y[j] <= s:
		z += y[j]
		if y[j] > m:
			w = j + 1
			m = y[j]
		q = j
		j += 1
	if q == len(y) - 1:
		print(0)
	elif m <= y[q + 1]:
		print(q + 2)
	elif m > y[q + 1]:
		print(w)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations, permutations
from bisect import *
from fractions import Fraction
from heapq import *
from random import randint

def main():
	for _ in range(int(input())):
		(n, s) = map(int, input().split())
		a = list(map(int, input().split()))
		if sum(a) <= s:
			print(0)
		else:
			(j, su) = (0, 0)
			while su < s:
				su += a[j]
				j += 1
			print(a.index(max(a[:j + 1])) + 1)
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')
main()


import sys

def check(arr, s, ind):
	sum = 0
	for i in range(len(arr)):
		if i != ind:
			sum += arr[i]
			if sum <= s:
				return False
	return True
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	ps = 0
	for i in range(n):
		ps += arr[i]
	maxi = -1
	ind = -1
	sum = 0
	for i in range(n):
		sum += arr[i]
		if arr[i] > maxi:
			maxi = arr[i]
			ind = i
		if sum > s:
			break
	if ps <= s:
		print(0)
	elif check(arr, s, ind):
		print(0)
	elif ind == n - 1:
		print(0)
	else:
		print(ind + 1)


import math
import os
import sys
from io import BytesIO, IOBase
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')
t = int(input())
for _ in range(t):
	(n, s) = [int(x) for x in input().split()]
	l = list([int(x) for x in input().split()])
	pos = 0
	for i in range(n):
		if l[i] > l[pos]:
			pos = i
		s -= l[i]
		if s < 0:
			break
	if s >= 0:
		pos = -1
	print(pos + 1)


case = int(input())
for _ in range(case):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	m = 0
	index = 0
	replace = False
	if sum(arr) <= s:
		print(0)
		continue
	i = 0
	max_element = 0
	_sum = 0
	while i < len(arr):
		_sum += arr[i]
		if _sum > s:
			m = max(arr[0:i + 1])
			index = arr.index(m)
			print(index + 1)
			break
		i += 1


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = [int(ii) for ii in input().split()]
	time = 0
	out = 0
	maxTime = 0
	q = 1
	for j in a:
		time += j
		if j > maxTime:
			maxTime = j
			out = q
		if time > s:
			print(out)
			break
		if time == s:
			qwe = 1
			if q == len(a):
				print(0)
				break
		q += 1
	if time < s:
		print(0)


t = int(input())
while t > 0:
	(n, s) = [int(ele) for ele in input().split()]
	a = [int(ele) for ele in input().split()]
	ind = 0
	if sum(a) <= s:
		print(ind)
	else:
		s1 = 0
		for i in range(n):
			s1 += a[i]
			if s1 > s:
				break
		print(a.index(max(a[:i + 1])) + 1)
	t -= 1


for i in range(int(input())):
	(n, s) = map(int, input().split())
	sum = 0
	ind = 0
	max1 = 0
	a = list(map(int, input().split()))
	for j in range(n):
		sum += a[j]
		if a[j] > max1:
			ind = j
			max1 = a[j]
		if sum - max1 > s:
			break
	if sum > s:
		if ind == j:
			if sum - max1 > s:
				max1 = 0
				for k in range(j):
					if a[k] > max1:
						ind = k
						max1 = a[k]
				if ind == j - 1:
					print(0)
				else:
					print(ind + 1)
			else:
				print(0)
		else:
			print(ind + 1)
	else:
		print(0)


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
for _ in [0] * RI():
	(nb, max_sums) = RMI()
	verse = RMI()
	sums = 0
	canbe = False
	for i in range(nb):
		sums += verse[i]
		if sums > max_sums:
			canbe = True
			break
	print([0, verse.index(max(verse[:i + 1])) + 1][canbe])


def main():
	t = int(input())
	for _ in range(t):
		(n, s) = map(int, input().split())
		a = list(map(int, input().split()))
		suma = M = total = already_skipped = 0
		for i in range(len(a)):
			suma += a[i]
			if a[M] < a[i]:
				M = i
			if suma > s:
				if already_skipped:
					break
				else:
					already_skipped = M + 1
					suma -= a[M]
			else:
				total += 1
		print(already_skipped)
main()


def ternary(n):
	if n == 0:
		return '0'
	nums = []
	while n:
		(n, r) = divmod(n, 3)
		nums.append(str(r))
	return ''.join(reversed(nums))
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	s = list(map(int, input().split()))
	s.append(1000000001)
	max_so_far = 0
	index = 0
	sum = 0
	for i in range(n):
		sum += s[i]
		if s[i] > max_so_far:
			max_so_far = s[i]
			index = i + 1
		if sum <= k and i == n - 1:
			print(0)
			break
		if sum > k:
			sum = sum - max_so_far + s[i + 1]
			if sum <= k:
				print(index)
			else:
				print(0)
			break


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, s) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	skip = [[float('inf'), -1]] * n
	noskip = [float('inf')] * n
	skip[0] = [s, 0]
	noskip[0] = s - arr[0]
	for i in range(1, n):
		if noskip[i - 1] > skip[i - 1][0] - arr[i]:
			skip[i] = [noskip[i - 1], i]
		else:
			skip[i] = [skip[i - 1][0] - arr[i], skip[i - 1][1]]
		noskip[i] = noskip[i - 1] - arr[i]
	ans = 0
	skipped = -1
	z = False
	for i in range(n):
		if skip[i][0] >= 0:
			if i >= ans:
				ans = i
				skipped = skip[i][1]
				z = True
		if noskip[i] >= 0:
			if i + 1 > ans:
				ans = i + 1
				z = False
				skipped = -1
	if skipped != -1:
		print(skipped + 1)
	else:
		print(0)


for _ in [0] * int(input()):
	(n, s) = map(int, input().split())
	(ans, max_, j) = (0, [0, 0], 1)
	for i in map(int, input().split()):
		if i > max_[1]:
			max_ = [j, i]
		s -= i
		if s < 0:
			ans = max_[0]
			break
		j += 1
	print(ans)


from collections import Counter
from collections import defaultdict
import math
import random

def inp():
	return map(int, input().split())
mod = int(1000000000.0) + 7

def solve(a, n):
	pass
for _ in range(int(input())):
	(n, s) = inp()
	a = list(inp())
	if sum(a) <= s:
		print(0)
	else:
		pre = [a[0]]
		for i in range(1, n):
			pre.append(pre[i - 1] + a[i])
		mx = 0
		idx = -1
		arr = []
		for i in range(n):
			if a[i] > mx:
				mx = a[i]
				idx = i
			arr.append(idx)
			pre[i] -= mx
		for i in range(n - 1, -1, -1):
			if pre[i] <= s:
				print(arr[i] + 1)
				break


import sys

def debug(*args):
	print(*args, file=sys.stderr)
t = int(input())
for _ in range(t):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	accum = n * [0]
	m_accum = n * [int(1000000000.0)]
	flag = True
	for i in range(n):
		accum[i] = accum[i - 1] + a[i] if i > 0 else a[i]
		if i > 0:
			if a[i] > m_accum[i - 1][0]:
				m_accum[i] = (a[i], i)
			else:
				m_accum[i] = m_accum[i - 1]
		else:
			m_accum[i] = (a[i], i)
		if flag and accum[i] - m_accum[i][0] > s:
			print(m_accum[i - 1][1] + 1)
			flag = False
	if flag and accum[-1] > s:
		print(m_accum[-1][1] + 1)
		flag = False
	if flag:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	m = [-1, -1]
	res = 0
	flag = 0
	i = 0
	while i < n:
		if m[0] < a[i]:
			m[0] = a[i]
			m[1] = i
		if res > s and a[i] > s:
			print(0)
			flag = 1
			break
		elif res > s and a[i] <= s:
			flag = 1
			print(m[1] + 1)
			break
		res += a[i]
		i += 1
	if flag == 0 and res > s:
		print(i)
	elif flag == 0:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	ind = 0
	for i in range(n):
		ans += a[i]
		if s < ans:
			max_ind = -1
			max_num = 0
			for j in range(i + 1):
				if max_num < a[j]:
					max_num = a[j]
					ind = j
			if i + 1 >= n:
				print(ind + 1)
			elif max_num > a[i + 1]:
				print(ind + 1)
			else:
				print(0)
			break
	else:
		print(0)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		sm = 0
		g = []
		for i in range(n):
			sm += a[i]
			g.append((a[i], i))
			if sm > s:
				if len(g) == 0:
					print(0)
				else:
					print(max(g)[1] + 1)
				break


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	k = 0
	check = 0
	maxi = 0
	for i in range(n):
		if k <= s and a[i] <= s:
			k = k + a[i]
			if k > s:
				check = 1
				if maxi > a[i]:
					break
				else:
					pos = i + 1
					break
			if maxi < a[i]:
				maxi = a[i]
				pos = i + 1
		else:
			check = 1
			pos = i + 1
			break
	if check == 1:
		print(pos)
	else:
		print(0)


t = int(input())
for q in range(t):
	(n, s) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	sumCheck = 0
	for i in a:
		sumCheck += i
	if sumCheck <= s:
		print(0)
		continue
	sumMin = 0
	idxMin = 0
	for i in range(n):
		sumMin += a[i]
		if sumMin > s:
			idxMin = i
			break
	ans = 0
	mx = 0
	for i in range(0, idxMin + 1):
		if mx < a[i]:
			mx = a[i]
			ans = i + 1
	print(ans)


def main():
	t = int(input())
	for _ in range(t):
		(n, s) = [int(x) for x in input().strip().split(' ')]
		a = [int(x) for x in input().strip().split(' ')]
		answer = solve(n, s, a)
		print(answer)

def solve(n, s, a):
	if s >= sum(a):
		return 0
	m = 0
	s -= a[0]
	if s < 0:
		return 1
	for (i, v) in enumerate(a[1:]):
		if v > a[m]:
			m = i + 1
		s -= v
		if s < 0:
			break
	return m + 1
main()


from sys import stdin, stdout
from math import *
for i in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	x = 0
	mx = 0
	mxind = -1
	t = 0
	ans = -1
	while x < n:
		if t + a[x] > s:
			if ans != -1:
				break
			else:
				if a[x] > mx:
					mx = a[x]
					mxind = x
				ans = mxind
				t -= mx
		else:
			t += a[x]
			if a[x] > mx:
				mx = a[x]
				mxind = x
		x += 1
	if sum(a) <= s:
		print(0)
	else:
		print(ans + 1)


T = int(input())
for i in range(T):
	flag = 0
	(n, s) = map(int, input().strip().split())
	A = list(map(int, input().strip().split()))
	j = 0
	p = 0
	S2 = [0] * len(A)
	S1 = [0] * len(A)
	S2[0] = A[0]
	for i in range(1, len(A)):
		if A[i] > A[j]:
			p = i
		S2[i] = S2[i - 1] + A[i]
		S1[i] = S2[i] - A[p]
		if S1[i] > s:
			print(j + 1)
			flag = 1
			break
		j = p
		p = j
	if flag == 1:
		continue
	if S2[-1] <= s:
		print(0)
	if S2[-1] > s:
		print(j + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = [int(i) for i in input().split()]
	k = 0
	for i in range(n):
		k = k + a[i]
	if k <= s:
		print('0')
	else:
		sum = 0
		max = 0
		for i in range(n):
			if sum > s:
				break
			else:
				sum = sum + a[i]
				if a[i] > max:
					max = a[i]
					j = i
		print(j + 1)


nn = int(input())

def nb_cadeau(l, santa):
	ss = 0
	ii = 0
	for el in l:
		ss += el
		ii += 1
		if ss > santa:
			return ii - 1
	return ii
for i in range(nn):
	f = list(map(int, input().split(' ')))
	n = f[0]
	s = f[1]
	items = list(map(int, input().split(' ')))
	if sum(items) <= s:
		print(0)
	else:
		cad = nb_cadeau(items, s)
		if cad > 0:
			print(items.index(max(items[:cad + 1])) + 1)
		else:
			print(1)


import os
import sys
from io import BytesIO, IOBase
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')

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

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush
from bisect import bisect_right

def main():
	for _ in range(N()):
		(n, s) = RL()
		arr = RLL()
		sm = [0]
		for i in range(n):
			sm.append(sm[-1] + arr[i])
		if sm[-1] <= s:
			print(0)
			continue
		ma = 0
		ind = -1
		for i in range(n):
			now = sm[i + 1]
			if arr[i] > ma:
				ma = arr[i]
				ind = i
			if now > s:
				print(1 + ind)
				break
main()


t = int(input())
for i in range(t):
	(n, s) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	need = -1
	if sum(a) <= s:
		print(0)
	else:
		for i in range(n):
			if a[i] > need:
				need = a[i]
				index = i
			if s - a[i] < 0:
				print(index + 1)
				break
			s -= a[i]


from sys import stdin
input = stdin.readline
R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, s) = R()
	a = list(R())
	v = []
	p = 0
	for i in a:
		p += i
		v += (p,)
	if v[-1] <= s:
		print(0)
	else:
		p = ans = ans1 = m = 0
		for i in range(n):
			l = i
			r = n - 1
			while l <= r:
				m = (l + r) // 2
				if v[m] - a[i] <= s:
					l = m + 1
					ans1 = m
				else:
					r = m - 1
			if ans1 >= ans:
				ans = ans1
				p = i + 1
			ans1 = 0
		print(p)


cases = int(input())
for t in range(cases):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = 0
	f = 0
	for i in range(n):
		if c + a[i] > s:
			f = i + 1
			break
		c += a[i]
	if f == 0:
		print(0)
	else:
		maxv = max(a[:f])
		if a[f - 1] < maxv:
			print(a.index(maxv) + 1)
		else:
			print(f)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	if sum(arr) <= s:
		print('0')
	else:
		summ = 0
		for i in range(n):
			summ += arr[i]
			if summ > s:
				x = i
				break
		maxx = 0
		for i in range(x + 1):
			if arr[i] > maxx:
				maxx = arr[i]
				ind = i
		print(ind + 1)


for t in range(int(input())):
	(n, s) = [*map(int, input().split())]
	a = [*map(int, input().split())]
	(skv, nskv) = (0, a[0])
	ind = 0
	pre = 0
	for (i, e) in enumerate(a[1:], 1):
		v1 = nskv
		v2 = skv + e
		skv = min(v1, v2)
		nskv += e
		if skv <= s:
			ind = ind if v2 < v1 else i
			pre = i
	v = 0
	spre = 0
	for e in a:
		if v + e <= s:
			v += e
			spre += 1
		else:
			break
	print(0 if pre < spre else ind + 1)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, s) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	maxi = 0
	summ = 0
	total = sum(a)
	for i in range(n):
		summ += a[i]
		if a[i] > a[maxi]:
			maxi = i
		if summ == s:
			if i < n - 1 and a[i + 1] < a[maxi]:
				stdout.write(str(maxi + 1) + '\n')
				break
			elif i < n - 1:
				stdout.write(str(i + 2) + '\n')
				break
		elif summ > s:
			stdout.write(str(maxi + 1) + '\n')
			break
	else:
		stdout.write('0\n')


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = []
	k = 0
	ans = 0
	sut = 0
	ind = 0
	for i in range(0, len(a)):
		ans += a[i]
		if a[i] > sut:
			sut = a[i]
			ind = i
		if ans > s:
			break
	if i != len(a) - 1:
		print(ind + 1)
	else:
		print('0')


for t in range(int(input())):
	(n, s) = map(int, input().split())
	maxi = -1
	ans = 0
	ps = 0
	for (i, j) in zip(range(1, n + 1), list(map(int, input().split()))):
		ps += j
		if maxi < j:
			if ps - j <= s:
				maxi = j
				ans = i
			else:
				break
		elif ps - maxi > s:
			break
	if ps <= s:
		ans = 0
	print(ans)


t = int(input())
for _ in range(t):
	(n, time) = map(int, input().split())
	mas = list(map(int, input().split()))
	c = 0
	maso = []
	for i in range(n):
		time -= mas[i]
		maso.append(mas[i])
		if time >= 0:
			continue
		else:
			break
	if time < 0:
		print(1 + mas.index(max(maso)))
	else:
		print(0)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [*map(int, input().split())]
	ans = -1
	for i in range(n):
		k -= a[i]
		if ans == -1 or a[i] > a[ans]:
			ans = i
		if k < 0 and i < n:
			print(ans + 1)
			break
	else:
		print(0)


for i in range(int(input())):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	(ok, dem, check) = (sum(arr), 0, 0)
	for j in range(len(arr)):
		dem += arr[j]
		if dem > s:
			dem -= max(arr[:j + 1])
			if j < len(arr) - 1 and dem + arr[j + 1] <= s:
				print(arr[:j + 1].index(max(arr[:j + 1])) + 1)
				check = 1
				break
			if j == len(arr) - 1:
				if dem - max(arr) <= s:
					print(arr.index(max(arr)) + 1)
					check = 1
					break
	if check == 0:
		print(0)


import sys

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

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

def oint():
	return int(input())
t = oint()
for _ in range(t):
	(n, s) = rint()
	a = list(rint())
	rs = []
	rs.append(a[0])
	for i in range(1, n):
		rs.append(rs[i - 1] + a[i])
	mmax = []
	mmax.append(0)
	for i in range(1, n):
		if a[mmax[i - 1]] < a[i]:
			mmax.append(i)
		else:
			mmax.append(mmax[i - 1])
	ansi = -1
	for i in range(n - 1, -1, -1):
		if rs[i] <= s:
			print(ansi + 1)
			break
		elif rs[i] - a[mmax[i]] <= s:
			print(mmax[i] + 1)
			break
	else:
		print(1)


def readVerse(parts, time):
	verses = list(map(int, input().split(' ')))
	(maxNumber, amountRead) = (0, 0)
	skipped = -1
	for i in range(parts):
		amountRead += verses[i]
		if verses[i] > maxNumber:
			biggestIndex = i
			maxNumber = verses[i]
		if amountRead > time:
			if skipped == -1:
				amountRead -= maxNumber
				skipped = biggestIndex
			else:
				return calcAmountRead(skipped, i)
	return calcAmountRead(skipped, i + 1)

def calcAmountRead(skipped, i):
	if skipped != -1:
		return skipped + 1
	else:
		return skipped + 1
t = int(input())
for x in range(t):
	(n, k) = map(int, input().split(' '))
	print(readVerse(n, k))


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(n, s) = getVars()
	a = getList()
	if sum(a) <= s:
		print(0)
		continue
	s1 = 0
	res = 0
	mindex = 0
	for i in range(n):
		if a[i] > a[mindex]:
			mindex = i
		s1 += a[i]
		if s1 > s:
			break
	print(mindex + 1)


t = int(input())
for _ in range(t):
	n = list(map(int, input().split()))
	l = list(map(int, input().split()))
	s = n[1]
	if sum(l) <= s:
		print(0)
	else:
		ma = -1
		ix = -1
		a = 0
		for i in range(n[0]):
			if a + l[i] > s:
				if l[i] > ma:
					ma = l[i]
					ix = i + 1
				break
			else:
				if l[i] > ma:
					ma = l[i]
					ix = i + 1
				a += l[i]
		print(ix)


t = int(input())
for _ in range(t):
	(n, s) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
	else:
		S = 0
		i = 0
		while S <= s:
			S += l[i]
			i = i + 1
		print(l.index(max(l[:i])) + 1)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from sys import stdin, stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def lessThanX(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def BinarySearch(a, x):
	i = bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def main():
	for i in range(ip()):
		(n, t) = ei()
		li = ai()
		id = 0
		for i in range(n):
			if li[i] > li[id]:
				id = i
			t -= li[i]
			if t < 0:
				break
		if t >= 0:
			id = -1
		print(id + 1)
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')

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))
ip = lambda : int(sys.stdin.readline().rstrip('\r\n'))
ai = lambda : list(map(int, sys.stdin.readline().split()))
ei = lambda : map(int, sys.stdin.readline().split())
main()


t = int(input())
for kk in range(t):
	(n, l) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	j = 0
	for i in range(n):
		if s[i] > s[j]:
			j = i
		l -= s[i]
		if l < 0:
			break
	if l >= 0:
		j = -1
	print(j + 1)


def main():
	for test in range(int(input())):
		(n, time_limit) = tuple(map(int, input().rstrip().split()))
		time_taken = list(map(int, input().rstrip().split()))
		skip_index = 0
		if sum(time_taken) > time_limit:
			time_elapsed = 0
			max_time = 0
			for (index, time) in enumerate(time_taken):
				time_elapsed += time
				if time > max_time:
					max_time = time
					skip_index = index + 1
				if time_elapsed > time_limit:
					break
		print(skip_index)
main()


q = int(input())
for _ in range(q):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	ma = arr[0]
	idx = 0
	if sum(arr) <= s:
		print(0)
		continue
	for (i, num) in enumerate(arr):
		s -= num
		if ma < num:
			ma = num
			idx = i
		if s < 0:
			if s + ma >= 0:
				print(idx + 1)
				break
			else:
				print(0)
				break


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = [int(st) for st in input().split()]
	maxPos = -1
	maxVal = 0
	total = 0
	cnt = 0
	for q in range(n):
		if total > s:
			break
		total += a[q]
		if total <= s:
			cnt += 1
		if a[q] > maxVal:
			maxVal = a[q]
			maxPos = q
	cnt2 = 0
	total = 0
	for q in range(n):
		if q == maxPos:
			continue
		total += a[q]
		if total > s:
			break
		cnt2 += 1
	if cnt2 > cnt:
		print(maxPos + 1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	l = list(input().split())
	l = [int(x) for x in l]
	sum = 0
	m = l[0]
	mn = 0
	flag = 0
	for j in range(1, n):
		if m <= l[j]:
			if sum + m <= s:
				sum = sum + m
				m = l[j]
				mn = j
			else:
				print(mn + 1)
				flag = 1
				break
		elif sum + l[j] <= s:
			sum += l[j]
		else:
			print(mn + 1)
			flag = 1
			break
	if flag == 0:
		if mn != n - 1:
			if sum + m > s:
				print(mn + 1)
			else:
				print('0')
		else:
			print('0')


no = int(input())
for i in range(no):
	(n, s) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	mx = a[0]
	su = 0
	for j in range(n):
		mx = max(mx, a[j])
		su += a[j]
		if su > s:
			print(a.index(mx) + 1)
			break
	if su <= s:
		print(0)


q = int(input())
for i in range(q):
	(n, s) = map(int, input().split())
	lst = list(map(int, input().split()))
	sum1 = 0
	max1 = 0
	dict1 = {}
	for i in range(len(lst)):
		sum1 += lst[i]
		if max1 <= lst[i]:
			max1 = lst[i]
			dict1[max1] = i
		if sum1 > s:
			break
	if sum(lst) <= s:
		print(0)
	else:
		print(dict1[max1] + 1)


t = int(input())
for i in range(0, t):
	ns = [int(n) for n in input().split()]
	(n, s) = (ns[0], ns[1])
	all = [int(i) for i in input().split()]
	ans = mxi = sm = mx = 0
	for i in range(0, n):
		sm = sm + all[i]
		if all[i] > mx:
			mx = all[i]
			mxi = i
		if sm > s:
			if sm - mx <= s:
				ans = mxi + 1
			else:
				break
	print(ans)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = [int(k) for k in input().split()]
	pou = sum(a)
	if pou <= s:
		print(0)
	elif pou - max(a) < s:
		print(a.index(max(a)) + 1)
	else:
		res = 0
		l = 0
		while res < s:
			res += a[l]
			l += 1
		y = a[:l + 1]
		print(a.index(max(y)) + 1)


from sys import stdin
from bisect import bisect_right

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

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())
debugging = 1

def dprint(*args):
	if debugging:
		print(*args)
	else:
		pass
t = intput()
for _ in range(t):
	(n, s) = intsput()
	a = list(intsput())
	accum = [0] * (n + 1)
	if sum(a) <= s:
		print(0)
		continue
	for i in range(n):
		accum[i + 1] = accum[i] + a[i]
	maxnum = 0
	bestans = 0
	for i in range(n):
		val = a[i]
		loc = bisect_right(accum, s + val)
		if loc - 1 > i:
			if loc - 2 > maxnum:
				maxnum = loc - 2
				bestans = i + 1
	print(bestans)


def main():
	(r, j) = ([], 0)
	for _ in range(int(input())):
		(n, t) = map(int, input().split())
		m = 0
		for (i, x) in enumerate(map(int, input().split()), 1):
			if m < x:
				(j, m) = (i, x)
			if t < x:
				r.append(j)
				break
			t -= x
		else:
			r.append(0)
	print('\n'.join(map(str, r)))
main()


q = int(input())
for i in range(q):
	(n, s) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	now_s = 0
	mx = 0
	mx_i = 0
	f = 0
	ans = 0
	for i in range(len(a)):
		now_s += a[i]
		if a[i] >= mx and f == 0:
			mx = a[i]
			mx_i = i
		if now_s > s:
			if f:
				break
			now_s -= mx
			f = 1
			ans = 1
			if now_s > s:
				ans = 0
				break
	if f == 1:
		if ans == 1:
			print(mx_i + 1)
		else:
			print(len(a) - 1)
	else:
		print(0)


(YES, NO) = ('Yes', 'No')

class Answer:

	def __init__(self, max=0, index=-1):
		self.max = max
		self.index = index

def prog(n, s, a):
	curr_sum = 0
	curr_max = 0
	max_idx = 0
	for i in range(0, n):
		if a[i] > curr_max:
			(curr_max, max_idx) = (a[i], i)
		curr_sum += a[i]
		if curr_sum > s:
			return max_idx + 1
	return 0
t = int(input())
while t > 0:
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	print(prog(n, s, a))
	t -= 1


n = int(input())
for j in range(n):
	(t, s) = map(int, input().split())
	v = [int(i) for i in input().split()]
	m1 = 0
	pulo1 = 0
	qt1 = 0
	flag = 1
	for i in range(t):
		if m1 + v[i] > s and flag:
			pulo1 = i + 1
			flag = 0
			continue
		elif m1 + v[i] <= s:
			m1 += v[i]
			qt1 += 1
		else:
			break
	if pulo1 == 0 and qt1 == t:
		print(0)
	elif m1 == 0:
		print(1)
	else:
		v2 = []
		m2 = 0
		pulo = 0
		qt2 = 0
		maior = -1
		id = -1
		for i in range(t):
			if m2 + v[i] <= s:
				v2.append(v[i])
				m2 += v[i]
				qt2 += 1
				if v[i] > maior:
					maior = v[i]
					id = i
			else:
				break
		pulo2 = id + 1
		m2 -= maior
		qt2 -= 1
		for i in range(len(v2), t):
			if m2 + v[i] <= s:
				m2 += v[i]
				qt2 += 1
			else:
				break
		if qt2 > qt1:
			print(pulo2)
		else:
			print(pulo1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	co = 0
	maxi = 0
	maxval = -1
	summ = 0
	if sum(arr) > k:
		for i in range(n):
			summ += arr[i]
			if maxval < arr[i]:
				maxval = arr[i]
				maxi = i
			if summ > k and co == 0:
				break
		print(maxi + 1)
	else:
		print(0)


def solve():
	(a, b) = map(int, input().split())
	lst = list(map(int, input().split()))
	sm = 0
	pos = 0
	mx = 0
	if sum(lst) <= b:
		print(0)
	else:
		for (i, j) in enumerate(lst):
			sm += j
			if j > mx:
				mx = j
				pos = i + 1
			if sm > b:
				print(pos)
				break
test = 1
test = int(input())
for i in range(test):
	solve()


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		continue
	else:
		sum_ = 0
		big = 0
		for i in range(n):
			if sum_ > s:
				break
			sum_ += a[i]
			if a[i] > big:
				big = a[i]
				index = i
		print(index + 1)


for jdgsdkjkjd in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		suuuummmm = 0
		mxxxxxxx = []
		for i in range(n):
			suuuummmm += a[i]
			mxxxxxxx.append((a[i], i))
			if suuuummmm > s:
				if len(mxxxxxxx) == 0:
					print(0)
				else:
					print(max(mxxxxxxx)[1] + 1)
				break


for i in range(int(input())):
	(n, s) = map(int, input().split())
	mas = list(map(int, input().split()))
	t = 0
	i = 0
	maxv = 0
	while True:
		t += mas[i]
		i += 1
		if i >= n or t >= s:
			i -= 1
			t -= mas[i]
			break
		if mas[i] > mas[maxv]:
			maxv = i
	if i == n - 1:
		print(0)
	elif mas[i + 1] < mas[maxv]:
		print(maxv + 1)
	else:
		print(0)


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(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

def SieveOfEratosthenes(n):
	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
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, s) = li()
	l = li()
	summm = sum(l)
	if summm <= s:
		print(0)
	else:
		ss = 0
		for i in range(n):
			ss += l[i]
			if ss > s:
				break
		print(l[:i + 1].index(max(l[:i + 1])) + 1)
t = 1
t = int(input())
for _ in range(t):
	solve()


import sys

def solve():
	(n, s) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	total = mx = mxi = i = 0
	removed = False
	best_before = -1
	while i < n:
		total += a[i]
		if not removed and mx < a[i]:
			mx = a[i]
			mxi = i + 1
		if total >= s and (not removed):
			best_before = i + (total == s)
			total -= mx
			removed = True
		if total >= s:
			break
		i += 1
	if removed and best_before < i:
		print(mxi)
	else:
		print(0)

def main():
	t = int(sys.stdin.readline())
	for _ in range(t):
		solve()
main()


test = int(input())
while test > 0:
	test -= 1
	line = input()
	line = line.split()
	n = int(line[0])
	s = int(line[1])
	line = input()
	line = line.split()
	a = list()
	for i in range(n):
		a += [int(line[i])]
	ma = 0
	poz = 0
	time = 0
	j = 0
	for i in range(n):
		if a[i] > ma:
			ma = a[i]
			poz = i
		time += a[i]
		if time > s:
			j = i
			time -= a[i]
			break
	else:
		print(0)
		continue
	time -= ma
	poz += 1
	if time + a[j] <= s:
		print(poz)
	else:
		print(0)


for __ in range(int(input())):
	(n, s) = list(map(int, input().split()))
	ar = list(map(int, input().split()))
	if sum(ar) <= s:
		print(0)
	else:
		ans = 0
		lol = ar[0]
		kek = 0
		ans1 = 0
		flag = 0
		for i in range(n):
			if ar[i] > lol and flag == 0:
				lol = ar[i]
				kek = i
			if s - ar[i] >= 0 and flag == 0:
				ans += 1
				s -= ar[i]
			elif s - ar[i] >= 0:
				ans1 += 1
				s -= ar[i]
			elif flag == 1:
				break
			else:
				ans1 = ans - 1
				s += lol
				flag = 1
				if s - ar[i] >= 0:
					ans1 += 1
					s -= ar[i]
				else:
					break
		print(kek + 1)


import collections
import heapq
import bisect
import math
import time

class Solution2:

	def solve(self, A1, A2):
		pass

def gcd(a, b):
	if not b:
		return a
	return gcd(b, a % b)

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

class Solution:

	def solve(self, A, s):
		if sum(A) <= s:
			return 0
		out = 0
		used = 0
		max_seen = 0
		for (i, n) in enumerate(A):
			if n > max_seen:
				used += max_seen
				max_seen = n
				if used > s:
					break
				out = i + 1
			else:
				used += n
			if used > s:
				break
		return out
sol = Solution()
sol2 = Solution2()
TT = int(input())
for test_case in range(TT):
	(N, K) = input().split()
	b = [int(c) for c in input().split()]
	out = sol.solve(b, int(K))
	print(str(out))


for i in range(int(input())):
	(n, s) = map(int, input().split())
	x = list(map(int, input().split()))
	sums = 0
	fg = 0
	for j in range(n):
		sums = sums + x[j]
		if sums > s:
			fg = 1
			break
	if fg == 1:
		print(x.index(max(x[:j + 1])) + 1)
	else:
		print(0)


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

def solve():
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	cs = [a[0]]
	for i in range(n - 1):
		cs.append(cs[-1] + a[i + 1])
	if cs[-1] <= s:
		print(0)
		return
	max_ = 0
	ans = 1
	for i in range(n):
		ns = s + a[i]
		j = bisect_right(cs, ns)
		if j <= i:
			continue
		if j - 1 > max_:
			ans = i + 1
			max_ = j - 1
	print(ans)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = []
	p = []
	su = 0
	maxis = [(0, 0)]
	maxi = -1
	maxi_index = -1
	for (i, x) in enumerate(input().split()):
		a.append(int(x))
		su += int(x)
		p.append(su)
		if int(x) > maxi:
			maxi = int(x)
			maxi_index = i
		maxis.append((maxi, maxi_index))
	index = -1
	parts = 0
	for i in range(n):
		if p[i] <= s:
			parts = i + 1
		elif p[i] - maxis[i][0] <= s and i > parts:
			index = maxis[i][1]
			parts = i
	if index == -1:
		print('0')
	else:
		print(index + 1)


t = int(input())
for r in range(t):
	m = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = 0
	s = 0
	i = 0
	for k in range(m[0]):
		s += a[k]
		if a[k] > c:
			c = a[k]
			i = k
		if s > m[1]:
			print(i + 1)
			break
	else:
		print('0')


t = int(input())
for i in range(t):
	(n, s) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	if sum(nums) <= s:
		print(0)
	else:
		max_so_far = -1
		max_position = -1
		found_best = False
		current_sum = 0
		for j in range(n):
			current_sum += nums[j]
			if nums[j] > max_so_far:
				max_so_far = nums[j]
				max_position = j
			if current_sum > s:
				print(max_position + 1)
				break


for j in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
	else:
		c = 0
		m = 0
		ik = -1
		ik1 = ik
		for i in range(n):
			if l[i] > m:
				m = l[i]
				ik = i
			if c + l[i] - m <= s:
				c += l[i]
				ik1 = ik
			else:
				break
		print(ik1 + 1)


def find_upper(lookup_array, item, start_point=0, find_if_higher=False, cur_index=0):
	for i in range(start_point, len(lookup_array)):
		if lookup_array[i] > item:
			return i
		if find_if_higher and i > cur_index:
			return -1
	return -1

def find_removable(verse_length, time_limit):
	sum_array = []
	max_array = [-1]
	summed = 0
	for i in verse_length:
		summed += i
		sum_array.append(summed)
		if i > max_array[-1]:
			max_array.append(i)
		else:
			max_array.append(max_array[-1])
	max_array.pop(0)
	final_index = find_upper(sum_array, time_limit)
	if final_index == -1:
		return 0
	maxi = max_array[final_index]
	new_index = find_upper(sum_array, time_limit + maxi, True, final_index + 1)
	if new_index == -1:
		return verse_length.index(maxi) + 1
	else:
		return 0
useless = int(input())
for i in range(useless):
	(n, time) = [int(i) for i in input().split()]
	verses = [int(i) for i in input().split()]
	print(find_removable(verses, time))


nn = int(input())
for i in range(nn):
	(n, s) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	summ = 0
	maxx = 0
	ind = -1
	indm = -1
	for i in range(n):
		flag = 0
		if a[i] > maxx:
			domax = indm
			maxx = a[i]
			indm = i
			flag = 1
		summ += a[i]
		if summ - maxx > s:
			ind = i - 1
			if flag:
				maxx = domax
				indm = domax
			break
	if ind == -1 and summ <= s:
		print(0)
	else:
		print(indm + 1)


itr = int(input())
for _ in range(itr):
	(n, t) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	l = list()
	remv = None
	mxm = 0
	for i in arr:
		if t - i >= 0:
			t -= i
			if i > mxm:
				mxm = i
		elif t - i < 0:
			if mxm > i:
				remv = mxm
			else:
				remv = i
			break
	if remv == None:
		print(0)
	else:
		print(arr.index(remv) + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = [int(i) for i in input().split()]
	works = True
	sm = 0
	for i in range(n):
		sm += a[i]
		if sm > s:
			works = False
			break
	if works:
		print(0)
	else:
		mx = max(a[:i + 1])
		print(a[:i + 1].index(mx) + 1)


t = int(input())
for querry in range(t):
	ns = input().split()
	n = int(ns[0])
	s = int(ns[1])
	total = 0
	mylist = input().split()
	x = 0
	most = [0, 0]
	while total < s and x < n:
		total = total + int(mylist[x])
		if most[0] < int(mylist[x]):
			most[0] = int(mylist[x])
			most[1] = x + 1
		if total <= s:
			x = x + 1
	mylist[most[1] - 1] = 0
	total = 0
	y = 0
	while total < s and y < n:
		total = total + int(mylist[y])
		if total < s:
			y = y + 1
	if x == n or x == y:
		print(0)
	else:
		print(most[1])


from bisect import bisect_right
t = int(input())
for _ in range(t):
	(n, s) = [int(p) for p in input().split()]
	arr = [int(p) for p in input().split()]
	cumSum = 0
	index = 0
	m = 0
	for i in range(len(arr)):
		cumSum += arr[i]
		if arr[i] > m:
			m = arr[i]
			index = i + 1
		if cumSum > s:
			print(index)
			break
		if cumSum <= s and i == len(arr) - 1:
			print(0)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		stop = False
		ind = 0
		ind_of_max = 0
		interestSum = 0
		totalSum = 0
		while ind < n and (not stop):
			totalSum += a[ind]
			if a[ind] > a[ind_of_max]:
				ind_of_max = ind
			interestSum = 0 if ind == 0 else totalSum - a[ind_of_max]
			if interestSum > s:
				stop = True
			else:
				ind += 1
		if stop:
			print(a.index(max(a[:ind])) + 1)
		else:
			print(a.index(max(a)) + 1)


from sys import stdin, stdout

def main():
	T = int(stdin.readline())
	for _ in range(T):
		(n, s) = list(map(int, stdin.readline().split()))
		arr = list(map(int, stdin.readline().split()))
		max = 0
		sum = 0
		pos = 0
		for (i, x) in enumerate(arr):
			if x > max:
				max = x
				pos = i + 1
			if sum + x > s:
				if i + 1 < len(arr) and sum - max + arr[i] + arr[i + 1] <= s:
					stdout.write(str(pos) + '\n')
					pos = -1
					break
				elif i + 1 == len(arr):
					stdout.write(str(i + 1) + '\n')
					pos = -1
					break
				else:
					stdout.write('0\n')
					pos = -1
					break
			sum += x
		if pos != -1:
			stdout.write('0\n')
main()


a = input()
a = int(a)
length = []
time = []
content = []
for i in range(a):
	b = input()
	length.append(int(b.split()[0]))
	time.append(int(b.split()[1]))
	c = input()
	content.append(c.split())
	for j in range(length[i]):
		content[i][j] = int(content[i][j])
for i in range(a):
	summer = 0
	counter = 0
	for j in range(length[i]):
		if summer + content[i][j] <= time[i]:
			counter += 1
			summer += content[i][j]
		else:
			break
	m = content[i][0:j + 1]
	if counter == length[i]:
		print(0)
	else:
		print(content[i].index(max(m)) + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split(' '))
	y = list(map(int, input().split()))
	s1 = m = ind = 0
	i = 0
	while s1 <= s and i < n:
		s1 += y[i]
		if m < y[i]:
			m = y[i]
			ind = i
		i += 1
	i = i - 1
	if i >= n - 1:
		print(0)
	elif y[i] > m:
		if y[i] > y[i + 1]:
			s = s - s1 + y[i]
			if s >= y[i + 1]:
				print(i)
			else:
				print(0)
		else:
			print(0)
	else:
		print(ind + 1)


t = int(input())
for test in range(t):
	[n, s] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
	else:
		cur_max = 0
		cur_index = 0
		i = 0
		d = 0
		sm = 0
		while i < n and d <= s:
			if a[i] > cur_max:
				d = d + cur_max
				cur_max = a[i]
				if d <= s:
					cur_index = i + 1
			else:
				d = d + a[i]
			sm = sm + a[i]
			i += 1
		print(cur_index)


t = int(input())
for i in range(t):
	(n, s) = input().split()
	n = int(n)
	s = int(s)
	a = list(map(int, input().split()))
	summ = 0
	index = -1
	maxx = a[0]
	maxind = 0
	flag = 1
	for i in range(n):
		summ += a[i]
		if maxx < a[i]:
			maxx = a[i]
			maxind = i
		if summ > s:
			break
		elif summ == s:
			if i + 1 < n:
				if a[i + 1] > maxx:
					maxind = i + 1
			break
	if flag != 0:
		if sum(a) <= s:
			print(0)
		else:
			print(maxind + 1)


import sys
import bisect as b
input = sys.stdin.readline

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

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

def solve(n, s, a):
	mxi = 0
	total = 0
	for i in range(0, n):
		if total + a[i] > s:
			return i + 1 if a[i] > a[mxi] else mxi + 1
		else:
			total += a[i]
			if a[i] > a[mxi]:
				mxi = i
	return 0
for i in range(inin()):
	(n, s) = cin()
	l = ain()
	print(solve(n, s, l))


t = int(input())
while t > 0:
	(n, m) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	summ = 0
	maxi = 0
	ind = 0
	for i in range(n):
		if summ <= m:
			summ += arr[i]
			if arr[i] > maxi:
				maxi = arr[i]
				ind = i + 1
		else:
			print(ind)
			break
	else:
		if summ > m:
			print(ind)
		else:
			print(0)
	t -= 1


t = int(input())
l2 = []
for i in range(0, t):
	(n, s) = map(int, input().split())
	l1 = list(map(int, input().split()))
	a = 0
	count = 0
	for j in range(n):
		a = a + l1[j]
		if a > s:
			count = 1
			break
	if count == 1:
		print(l1.index(max(l1[:j + 1])) + 1)
	else:
		print(0)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	asum = 0
	for i in range(n):
		asum += a[i]
		if asum > s:
			print(a.index(max(a[:i + 1])) + 1)
			break
	else:
		print(0)


for _ in range(int(input())):
	(n, s) = [int(x) for x in input().split()]
	verses = [int(x) for x in input().split()]
	tot = 0
	max_ = 0
	highest = 0
	for (i, verse) in enumerate(verses):
		if verse + tot > s:
			if verse > max_:
				highest = i
				max_ = verse
			break
		tot += verse
		if verse > max_:
			highest = i
			max_ = verse
	if i + 1 == len(verses):
		print(0)
	else:
		print(highest + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if len(l) == 1:
		if s >= l[0]:
			print(0)
		else:
			print(1)
	else:
		l2 = []
		for i in range(n):
			s -= l[i]
			l2.append(l[i])
			if s < 0:
				s += l[i]
				i = i - 1
				break
		if i == n - 1:
			print(0)
		else:
			j = i
			m = max(l2)
			for i in range(len(l2)):
				if m == l[i]:
					if s + m > l[j + 1]:
						print(i + 1)
					else:
						print(0)
					break


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	mx = -1
	r = 0
	sum = 0
	for (inx, i) in enumerate(l, 1):
		sum += i
		if sum > s:
			break
		if i > mx:
			mx = i
			r = inx
	if sum <= s:
		print(0)
	elif i > mx:
		print(inx)
	else:
		print(r)


t = int(input())
for _ in range(t):
	(n, s) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	t = 0
	maxAIdx = -1
	maxT = 0
	maxTminusOne = 0
	skipIdx = -1
	for i in range(n):
		t += a[i]
		if maxAIdx == -1:
			maxAIdx = 0
		elif a[i] > a[maxAIdx]:
			maxAIdx = i
		if t <= s:
			maxT = i + 1
		if t - a[maxAIdx] <= s:
			maxTminusOne = i + 1 - 1
			skipIdx = maxAIdx
	if maxT >= maxTminusOne:
		print(0)
	else:
		print(skipIdx + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	j = 0
	k = 0
	cnt = 0
	ans = 0
	mx = 0
	for i in range(n):
		k += a[i]
		if a[i] > mx:
			mx = a[i]
			ans = i + 1
		if k > s:
			break
		cnt += 1
	if cnt == n:
		print(0)
	else:
		print(ans)


for i in range(int(input())):
	(n, s) = [int(x) for x in input().split()]
	data = [int(x) for x in input().split()]
	data1 = data[:]
	ans = 0
	for j in range(1, n):
		data[j] += data[j - 1]
		if data[j] > s:
			ans = data1.index(max(data1[:j + 1])) + 1
			break
	print(ans)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	pi = -1
	sv = 0
	for i in range(n):
		sv += a[i]
		if sv > s:
			pi = i
			break
	if pi == -1:
		print(0)
	else:
		m = max(a[:i + 1])
		if i == n - 1 or a[i + 1] < m:
			print(a.index(m) + 1)
		else:
			print(0)


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n, s):
	if sum(arr) <= s:
		write(0)
		return
	(i, sums) = (0, 0)
	seen = []
	while i < n:
		sums += arr[i]
		seen.append(arr[i])
		if sums > s:
			break
		i += 1
	write(seen.index(max(seen)) + 1)

def main():
	for _ in range(r_int()):
		(n, s) = r_array()
		arr = r_array()
		solution(arr, n, s)
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 write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


t = int(input())
for i in range(t):
	inp = list(map(int, input().split()))
	n = inp[0]
	s = inp[1]
	inp = list(map(int, input().split()))
	maxi = [inp[0]]
	cum = [inp[0]]
	sumi = inp[0]
	it = inp[0]
	maxin = [0]
	a = 0
	for j in range(1, len(inp)):
		if it < inp[j]:
			it = inp[j]
			a = j
		sumi += inp[j]
		cum.append(sumi)
		maxi.append(it)
		maxin.append(a)
	j = len(inp) - 1
	if sum(inp) <= s:
		print(0)
	else:
		while j >= 0:
			if cum[j] - maxi[j] <= s:
				print(maxin[j] + 1)
				break
			j -= 1


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	x = 0
	f = 0
	ind = 0
	ans = 0
	for i in range(len(a)):
		x += a[i]
		if ans < a[i]:
			ans = a[i]
			ind = i
		if x > s:
			f = 1
			break
	if f == 0:
		print(0)
	else:
		print(ind + 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	A = list(map(int, input().split()))
	m = 0
	sum = 0
	for i in range(1, n):
		if A[i] > A[m]:
			S = sum + A[m]
		else:
			S = sum + A[i]
		if S <= s:
			sum = S
			if A[i] > A[m]:
				m = i
		else:
			break
	if sum + A[m] <= s:
		m = -1
	print(m + 1)


import sys
reader = (list(map(int, line.split())) for line in sys.stdin)
input = reader.__next__
(t,) = input()
for _ in range(t):
	(n, s) = input()
	a = list(input())
	i = 0
	left = 0
	maxSt = 0
	maxId = -1
	while i < n:
		left += a[i]
		if maxSt < a[i]:
			maxSt = a[i]
			maxId = i
		if left > s:
			break
		i += 1
	if i == n:
		print(0)
	else:
		print(maxId + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	if sum(a) <= s:
		print(0)
	else:
		sumi = 0
		for i in range(0, len(a)):
			sumi += a[i]
			if sumi > s:
				b = a[:i + 1]
				break
		print(a.index(max(b)) + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	k = s
	i = 0
	mx = a[0]
	ind = 0
	flag = 0
	if sum(a) <= s:
		print(0)
	else:
		while s > 0 and i < n:
			s -= a[i]
			if a[i] >= mx:
				mx = a[i]
				ind = i
			i += 1
		ans = 0
		if i < n:
			if s + mx >= a[i]:
				ans = ind + 1
		elif i == n:
			if mx > a[i - 1]:
				ans = ind + 1
		print(ans)


for _ in range(int(input())):
	(n, s) = tuple(map(int, input().split()))
	verse = tuple(map(int, input().split()))
	mx = 0
	sm = 0
	for i in range(n):
		mx = max(mx, verse[i])
		sm += verse[i]
		if sm > s:
			print(verse.index(mx) + 1)
			break
	else:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
	elif n == 1:
		if l[0] > s:
			print(1)
		else:
			print(0)
	else:
		r = 0
		ans = 0
		max = 0
		for i in range(n):
			c = 0
			val = 0
			if l[i] > max:
				max = l[i]
				p = l[0:i] + l[i + 1:]
				for j in range(len(p)):
					val = val + p[j]
					if val > s:
						break
					elif val == s:
						c += 1
						break
					else:
						c += 1
				if c > r:
					r = c
					ans = i + 1
		print(ans)


t = int(input())
for i in range(t):
	line = input()
	(n, s) = list(map(int, line.strip().split()))
	line = input()
	nums = list(map(int, line.strip().split()))
	summ = 0
	i = 0
	mmax = -1
	mmax_idx = -1
	while summ <= s and i < n:
		summ += nums[i]
		if nums[i] > mmax:
			mmax = nums[i]
			mmax_idx = i
		i += 1
	if summ <= s:
		print(0)
		continue
	print(mmax_idx + 1)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
	else:
		cur = 0
		j = 0
		for i in range(n):
			if l[i] > l[j]:
				j = i
			s -= l[i]
			if s < 0:
				break
		print(j + 1)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, s) = [int(x) for x in input().strip().split()]
	a = [int(x) for x in input().strip().split()]
	sec = 0
	i_max = 0
	a_max = 0
	f = False
	ans = 0
	for (i, aa) in enumerate(a):
		sec += aa
		if a_max < aa:
			a_max = aa
			i_max = i + 1
		if sec > s:
			f = True
			ans = i_max
			break
	print(ans)


for i in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	pre = [arr[0]]
	for i in arr[1:]:
		pre.append(i + pre[-1])
	if pre[-1] <= k:
		print(0)
	else:
		mx = -10 ** 9
		ind = -1
		for i in range(len(pre)):
			if pre[i] - arr[i] <= k:
				if mx < arr[i]:
					mx = arr[i]
					ind = i
			else:
				break
		print(ind + 1)


for i in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		continue
	j = 0
	t = 0
	suma = 0
	mx = 0
	ans = 0
	for i in range(n):
		if suma + a[i] > s:
			if a[i] > mx:
				ans = i + 1
			break
		else:
			if a[i] > mx:
				mx = a[i]
				ans = i + 1
			suma += a[i]
	print(ans)


t = int(input())
answer = []
for i in range(t):
	(n, s) = [int(j) for j in input().split()]
	a = [int(j) for j in input().split()]
	ind1 = 0
	ind2 = 0
	end = False
	for j in range(n):
		if a[j] > a[ind1]:
			ind2 = ind1
			s -= a[ind2]
			ind1 = j
		if j != ind1:
			s -= a[j]
		if s < 0:
			break
		if j == n - 1:
			end = True
	if end and s - a[ind1] >= 0:
		answer.append(0)
	elif end:
		answer.append(ind1 + 1)
	elif j == ind1:
		answer.append(ind2 + 1)
	else:
		answer.append(ind1 + 1)
for i in answer:
	print(i)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = a[0]
	mxind = -1
	mxind1 = 0
	sn = 0
	for i in range(n):
		sn += a[i]
		if a[i] >= mx:
			mxind1 = i
			mx = a[i]
		if sn > s:
			sn -= a[mxind1]
			mxind = mxind1
			break
	if mxind == -1:
		print(0)
	else:
		print(mxind + 1)


from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	l = [int(x) for x in input().split()]
	ar = []
	temp = 0
	if sum(l) <= s:
		print(0)
	else:
		for i in l:
			temp += i
			if temp > s:
				ar.append(i)
				break
			ar.append(i)
		if len(ar) == 0:
			print(1)
		else:
			ans = 0
			m = 0
			for i in range(len(ar)):
				if ar[i] > m:
					m = ar[i]
					ans = i + 1
			print(ans)


from itertools import accumulate
T = int(input())
for cc in range(T):
	(n, m) = [int(_) for _ in input().split()]
	a = [int(_) for _ in input().split()]
	if sum(a) <= m:
		print(0)
		continue
	partial_sum = accumulate(a)
	for (i, ps) in enumerate(partial_sum):
		if ps > m:
			print(1 + a.index(max(a[:i + 1])))
			break


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= m:
		print(0)
	else:
		s = 0
		ma = -10 ** 12
		ind = -1
		for i in range(n):
			s += a[i]
			if a[i] >= ma:
				ind = i
				ma = a[i]
			if s > m:
				break
		if i != n - 1:
			if ma >= a[i + 1]:
				print(ind + 1)
			else:
				print(0)
		elif i == n - 1:
			if ma >= a[-1]:
				print(ind + 1)
			else:
				print(0)
		else:
			print(0)


def runcase():
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	t = 0
	m = 0
	index = 0
	for i in range(n):
		t += a[i]
		if a[i] > m:
			m = a[i]
			index = i + 1
		if t >= s:
			if i == n - 1:
				print(0)
			elif a[i + 1] >= m:
				print(0)
			else:
				print(index)
			return
	print(0)
for _ in range(int(input())):
	runcase()


T = int(input())
for t in range(T):
	(n, s) = map(int, input().split())
	v = list(map(int, input().split()))
	tot = 0
	j = 0
	for i in range(n):
		tot += v[i]
		if tot - max(v[i], v[j]) > s:
			tot -= v[i]
			break
		if v[i] > v[j]:
			j = i
	if tot <= s:
		print(0)
	else:
		print(j + 1)


for _ in range(int(input())):
	li = list(map(int, input().split()))
	(li2, sm) = (list(map(int, input().split())), 0)
	if sum(li2) <= li[1]:
		print(0)
	for i in range(len(li2)):
		sm += li2[i]
		if sm > li[1]:
			print(li2.index(max(li2[:i + 1])) + 1)
			break


t = int(input())
from itertools import accumulate
import bisect
for _ in range(t):
	(n, s) = map(int, input().split())
	A = list(map(int, input().split()))
	C = [0] + A
	C = list(accumulate(C))
	if C[-1] <= s:
		print(0)
		continue
	max_ = 0
	ans = -1
	for i in range(n):
		if C[i + 1] - A[i] > s:
			continue
		j = bisect.bisect_right(C, s + A[i])
		if j - 2 >= max_:
			max_ = j - 2
			ans = i + 1
	print(ans)


import sys, math
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(n, time) = map(int, input().split())
	mas = list(map(int, input().split()))
	c = 0
	maso = []
	for i in range(n):
		time -= mas[i]
		maso.append(mas[i])
		if time >= 0:
			continue
		else:
			break
	if time < 0:
		print(1 + mas.index(max(maso)))
	else:
		print(0)


import sys
from math import gcd
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
Judge = 0
if Judge:
	sys.stdin = open('input.in', 'r')
for _ in range(inp()):
	(n, s) = mulip()
	a = lst()
	sm = 0
	ans = 0
	idx = 0
	for i in range(n):
		if a[i] > a[idx]:
			idx = i
		sm += a[i]
		if sm > s and sm - a[idx] <= s:
			ans = idx + 1
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	total = l[0]
	max_index = 0
	maximum = l[0]
	flag = 0
	for j in range(1, n):
		if flag == 0 and total + l[j] > k:
			flag = 1
			if l[j] > maximum:
				maximum = l[j]
				max_index = j
			else:
				total -= l[max_index]
		elif flag == 1 and total + l[j] > k:
			break
		else:
			total += l[j]
			if l[j] > maximum:
				maximum = l[j]
				max_index = j
	if flag == 0:
		print(0)
	else:
		print(max_index + 1)


import math
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	i = 0
	j = 0
	maxa = arr[0]
	summ = 0
	initial = 0
	add = 0
	temp = 0
	maxInd = 0
	for i in range(n):
		if summ + arr[i] <= s:
			summ = summ + arr[i]
			if arr[i] >= maxa:
				maxa = arr[i]
				maxInd = i
			j = i
		else:
			if arr[i] > maxa:
				maxa = arr[i]
				maxInd = i
				j = i
			break
		initial = j + 1
	if j == n - 1:
		print('0')
	else:
		j = j + 1
		while j < n:
			if temp + arr[j] <= maxa:
				add += 1
				temp = temp + arr[j]
				j += 1
			else:
				break
		if add > 0:
			print(maxInd + 1)
		else:
			print('0')


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	p = 0
	ma = 0
	ind = -1
	e = -1
	fl = 0
	ni = -1
	for i in range(n):
		if fl == 0 and a[i] + p <= s:
			p += a[i]
			if a[i] > ma:
				ma = a[i]
				ind = i
			e = i
		elif fl == 0 and a[i] + p > s:
			fl = 1
			ni = i
		else:
			break
	if fl == 0:
		print(0)
	elif ind == -1:
		print(1)
	elif a[ni] > a[ind]:
		print(ni + 1)
	else:
		print(ind + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [*map(int, input().split())]
	cnt = 0
	x = 0
	num = 0
	for i in range(n):
		x += l[i]
		if x <= k:
			continue
		else:
			if num >= 1:
				break
			z = max(l[:i + 1])
			x -= z
			cnt = l.index(z) + 1
			num += 1
			if x <= k:
				continue
			else:
				break
	print(cnt)


t = int(input())
for tt in range(t):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = []
	sm = 0
	f = 1
	for i in arr:
		if i + sm > s:
			f = 0
			ans.append(i)
			break
		else:
			sm += i
			ans.append(i)
	if f == 1:
		print('0')
	else:
		print(ans.index(max(ans)) + 1)


from operator import itemgetter
t = int(input())

def solve(n, s, a):
	a2 = [(a[i], i) for i in range(n)]
	remain = s
	flag = True
	for i in range(n):
		s -= a[i]
		if s < 0:
			flag = False
			a3 = a2[:i + 1]
			(_, p) = max(a3, key=itemgetter(0))
			print(p + 1)
			break
	if flag:
		print(0)
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	solve(n, s, a)


def test(arr, begin, end, tmp, s):
	cnt = 0
	for i in range(begin, end):
		tmp += arr[i]
		if tmp > s:
			return cnt
		else:
			cnt += 1
	return cnt

def solve(arr, s, n):
	tmp = 0
	ind = n
	m = 0
	m_ind = -1
	for i in range(n):
		tmp += arr[i]
		if tmp > s:
			ind = i
			tmp -= arr[i]
			break
		elif m < arr[i]:
			m = arr[i]
			m_ind = i
	if ind == n:
		return 0
	cnt1 = test(arr, ind, n, tmp - m, s)
	cnt2 = test(arr, ind + 1, n, tmp, s)
	if max(cnt1, cnt2) == 0:
		return 0
	elif cnt1 > cnt2 + 1:
		return m_ind + 1
	else:
		return ind + 1
m = int(input())
for i in range(m):
	(n, s) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	print(solve(arr, s, n))


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	if sum(a) <= s:
		print(0)
	else:
		sum_till_here = 0
		mi = 0
		for i in range(n):
			if sum_till_here <= s:
				sum_till_here += a[i]
				if a[i] > a[mi]:
					mi = i
		print(mi + 1)


def check(n, s, time):
	totalTime = [0] * n
	realTimeSum = 0
	timeSum = 0
	skipped = 0
	ans = 0
	maxTime = time[0]
	maxTimeIdx = 0
	for (i, t) in enumerate(time):
		timeSum += t
		realTimeSum += t
		if t > maxTime:
			maxTime = t
			maxTimeIdx = i
		if timeSum > s:
			if skipped == 0:
				skipped += 1
				ans = maxTimeIdx
				timeSum -= maxTime
			else:
				break
	if realTimeSum <= s:
		return 0
	return ans + 1
numTestCase = int(input())
for i in range(numTestCase):
	(n, s) = map(int, input().split())
	time = list(map(int, input().split()))
	print(check(n, s, time))


T = int(input())
for t in range(T):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	su = sum(arr)
	if su <= s:
		print(0)
		continue
	ma = 0
	sb = 0
	ind = -1
	count = 0
	for i in range(n):
		if arr[i] + sb <= s:
			sb += arr[i]
			count += 1
			if arr[i] > ma:
				(ma, ind) = (arr[i], i)
		else:
			if arr[i] > ma:
				(ma, ind) = (arr[i], i)
			break
	count2 = 0
	sb = 0
	for i in range(n):
		if i != ind:
			if arr[i] + sb <= s:
				sb += arr[i]
				count2 += 1
			else:
				break
	if count2 >= count:
		print(ind + 1)
	else:
		print(0)


import math
x = list(map(int, input().split()))
y = []
v = []
ind = []
for i in range(0, x[0]):
	z = list(map(int, input().split()))
	y.append(z[1])
	z = list(map(int, input().split()))
	v.append(z)
	ind.append(0)
for i in range(0, x[0]):
	s = 0
	m = 0
	for j in range(0, len(v[i])):
		s += v[i][j]
		if v[i][j] > m:
			m = v[i][j]
			if s - m <= y[i]:
				ind[i] = j + 1
			else:
				break
		if j == len(v[i]) - 1 and s <= y[i]:
			ind[i] = 0
for i in range(0, x[0]):
	print(ind[i])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		if l[i] > l[ans]:
			ans = i
		k -= l[i]
		if k < 0:
			break
	if k >= 0:
		ans = -1
	print(ans + 1)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
t = I()
for i in range(0, t):
	(n, s) = li()
	a = li()
	c = i = d = m = p = 0
	while i < n:
		c = c + a[i]
		d += 1
		if a[i] > m:
			m = a[i]
			p = i
		i += 1
		if c >= s:
			break
	if c > s:
		d -= 1
	c = k = 0
	for i in range(n):
		if i != p:
			c = c + a[i]
			k += 1
		if c >= s:
			break
	if c > s:
		k -= 1
	if k > d:
		print(p + 1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	pref = [a[0]]
	for i in range(1, n):
		pref.append(pref[-1] + a[i])
	if pref[-1] <= s:
		print(0)
	else:
		res = 0
		total = 0
		m = a[0]
		for i in range(1, n):
			temp = m
			m = max(m, a[i])
			total = pref[i] - m
			if total <= s:
				if m > temp:
					res = i + 1
		print(res if res else 1)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	flag = 1
	while s >= 0 and i < n:
		if s - a[i] >= 0:
			s -= a[i]
			i += 1
			continue
		else:
			print(a.index(max(a[:i + 1])) + 1)
			flag = 0
			break
	if flag == 1:
		print(0)


for i in range(int(input())):
	sum1 = 0
	(n, s) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	max1 = a[0]
	flag = 0
	i = 0
	while sum1 <= s and i < len(a):
		if a[i] > max1:
			max1 = a[i]
		sum1 += a[i]
		if i < len(a) - 1:
			i += 1
		else:
			flag = 1
			break
	if flag == 1 and sum1 <= s:
		print('0')
		continue
	elif flag == 1 and sum1 > s:
		print(len(a))
		continue
	else:
		i += 1
		print(a.index(max1) + 1)
		continue


t = int(input())
while t:
	t += -1
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	m = l[0]
	ans = 1
	tem = 0
	ind = -1
	for i in range(n):
		if l[i] >= m:
			m = l[i]
			ans = i + 1
		tem += l[i]
		if tem >= s:
			ind = i + 1
			break
	if ind == -1:
		print(0)
	elif ind <= n - 1:
		if l[ind] >= m:
			print(0)
		else:
			print(ans)
	else:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	ans = 0
	i = 0
	maxm = 0
	ind = 0
	while ans <= s and i < n:
		ans += arr[i]
		if maxm < arr[i]:
			maxm = arr[i]
			ind = i
		i += 1
	if ans <= s and i == n:
		print(0)
	else:
		print(ind + 1)


T = int(input())
for _ in range(T):
	(N, S) = map(int, input().split())
	A = list(map(int, input().split()))
	time = 0
	maxv = [0, 0]
	for (i, a) in enumerate(A):
		if time + a > S:
			if maxv[1] > a:
				print(maxv[0] + 1)
				break
			else:
				print(i + 1)
				break
		time += a
		if maxv[1] < a:
			maxv = [i, a]
	else:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	pref_max = 0
	pref_sum = 0
	ans = 0
	for i in range(n):
		pref_max = max(pref_max, a[i])
		pref_sum += a[i]
		if pref_sum - pref_max > s:
			break
		if pref_max == a[i]:
			ans = i
	if sum(a) <= s:
		print(0)
	else:
		print(ans + 1)


def main(n, s, l):
	(sums, i) = (0, 0)
	vals = {}
	while i < len(l):
		vals[i] = int(l[i])
		sums += int(l[i])
		if sums > s:
			break
		i += 1
	if sums <= s:
		print('0')
		return
	x = list(vals.values())
	m = x.index(max(x)) + 1
	print(m)

def runner():
	val = input()
	for i in range(int(val)):
		ans = input()
		ans = ans.split(' ')
		b = input()
		b = b.split(' ')
		main(int(ans[0]), int(ans[1]), b)
runner()


for i in range(int(input())):
	(n, s) = map(int, input().split())
	a = [int(s) for s in input().split()]
	summ = 0
	for j in range(n):
		summ += a[j]
		if summ > s:
			print(a[:j + 1].index(max(a[:j + 1])) + 1)
			break
	else:
		print(0)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	sm = sum(a)
	mx = max(a)
	idx = a.index(mx)
	if sm <= s:
		print(0)
	elif sm - mx <= s:
		print(idx + 1)
	else:
		sm = 0
		idx = 0
		mx = a[0]
		for i in range(n):
			if sm > s:
				break
			if mx < a[i]:
				mx = a[i]
				idx = i
			sm += a[i]
		print(idx + 1)


def process(t, arr):
	a = 0
	m = 0
	skip = 0
	for (i, ar) in enumerate(arr):
		a = a + ar
		if a - m > t:
			if a - ar <= t:
				return i + 1
			return skip + 1
		if ar > m:
			m = max(m, ar)
			skip = i
	else:
		if a > t:
			return skip + 1
		else:
			return 0
s = input()
cases = int(s)
for case in range(cases):
	s = input()
	(_, t) = [int(s) for s in s.split()]
	s = input()
	arr = [int(s) for s in s.split()]
	print(process(t, arr))


def count_verses(verses, length, maximum):
	biggest_index = 0
	i = 0
	while i < length and maximum >= 0:
		biggest_index = i if verses[i] > verses[biggest_index] else biggest_index
		maximum -= verses[i]
		i += 1
	if maximum < 0:
		return biggest_index + 1
	return 0

def solution(inp1, inp2):
	length = inp1[0]
	maximum = inp1[1]
	return count_verses(inp2, length, maximum)

def main():
	inp1 = input()
	length = int(inp1)
	for i in range(length):
		inp1 = list(map(int, input().split()))
		inp2 = list(map(int, input().split()))
		result = solution(inp1, inp2)
		print(result)
main()


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		continue
	mx = 0
	sm = 0
	end = -1
	for i in range(n):
		sm += a[i]
		if a[i] > a[mx]:
			mx = i
		if sm > s:
			end = i
			break
	print(mx + 1)


t = int(input())
while t:
	t -= 1
	(n, s) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if sum(a) <= s:
		print(0)
	elif n == 1:
		print(0)
	else:
		sm = 0
		id = -1
		flag = 0
		i = 0
		b = []
		while i < n:
			sm += a[i]
			if sm <= s:
				b += [a[i]]
			else:
				if len(b) == 0:
					flag = 1
					id = i
					break
				mx = max(b)
				if a[i] > mx:
					id = i
					sm -= a[i]
				else:
					id = a.index(mx)
					sm -= mx
				if sm <= s:
					flag = 1
				break
			i += 1
		if flag == 0:
			print(0)
		else:
			print(id + 1)


from collections import defaultdict as dc
import sys
import math
mod = 10 ** 9 + 7

def bs(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def binarysearchforsolvingeqautions(a, i, l, r):
	while 1:
		mid = (l + r) / 2
		(p, q) = force(a, mid, i)
		if abs(p - q) < 1e-13:
			return mid
		elif p > q:
			l = mid
		else:
			r = mid

def bs(a, b):
	l = a
	r = b + 1
	x = b
	ans = 0
	while l < r:
		mid = (l + r) // 2
		if x | mid > ans:
			ans = x | mid
			l = mid + 1
		else:
			r = mid
	return ans

def digit(n):
	a = []
	while n > 0:
		a.append(n % 10)
		n = n // 10
	return a

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

def line():
	p = list(map(int, input().split()))
	return p

def ans(n, s, a):
	if s >= sum(a):
		return 0
	m = -1
	j = 0
	for i in range(n):
		s = s - a[i]
		if m < a[i]:
			m = a[i]
			j = i + 1
		if s < 0:
			return j
	return 0
for _ in range(inp()):
	(n, s) = line()
	a = line()
	print(ans(n, s, a))


from sys import stdin
m = int(input())
for i in range(m):
	(n, s) = map(int, input().rstrip().split(' '))
	l = list(map(int, input().rstrip().split(' ')))
	currTot = 0
	c = 0
	if s >= sum(l):
		print(0)
	else:
		while currTot + l[c] < s:
			currTot += l[c]
			c += 1
		currTot += l[c]
		if c < n - 1 and l[c + 1] >= max(l[0:c + 1]):
			print(0)
		else:
			print(l.index(max(l[0:c + 1])) + 1)


for i in range(int(input())):
	(n, s) = map(int, input().split())
	m = list(map(int, input().split()))
	summ = 0
	counter = 0
	while summ <= s and counter < n:
		summ += m[counter]
		counter += 1
	if summ > s:
		counter -= 1
	mx = m.index(max(m[0:counter + 1]))
	if counter == n:
		print(0)
	else:
		print(mx + 1)


n = int(input())
for i in range(n):
	(s1, t1) = map(int, input().split())
	a = list(map(int, input().split()))
	t = 0
	f = 0
	s = 0
	max = a[0]
	for j in range(1, s1):
		if a[j] >= max:
			if max + s > t1:
				f = 1
				break
			if max + s == t1:
				t = j
				f = 1
				break
			s = s + max
			max = a[j]
			t = j
		else:
			s = s + a[j]
			if t1 <= s:
				break
	if s + max <= t1:
		print(0)
	else:
		print(t + 1)


t = int(input())
while t:
	(n, s) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	j = 0
	d = {}
	m = 0
	for i in range(n):
		if c + l[i] < s:
			c += l[i]
			d[l[i]] = i + 1
			if l[i] > m:
				m = l[i]
		else:
			c += l[i]
			d[l[i]] = i + 1
			if m < l[i]:
				m = l[i]
			if i != n - 1:
				if c - m + l[i + 1] < c:
					j = d[m]
					break
				else:
					break
	print(j)
	t -= 1


t = int(input())
for kek in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	pos = list()
	pos.append([a[0], 0])
	ind = 0
	for i in range(1, len(a)):
		if a[i] >= a[ind]:
			ind = i
		pos.append([pos[-1][0] + a[i], ind])
	ans = 0
	for i in range(len(a)):
		if s - pos[i][0] + a[pos[i][1]] >= 0:
			ans = pos[i][1] + 1
	if sum(a) <= s:
		print(0)
	else:
		print(ans)


import sys
readline = sys.stdin.readline
from itertools import accumulate
from bisect import bisect as br
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(N, S) = map(int, readline().split())
	A = list(map(int, readline().split()))
	AA = list(accumulate(A))
	if sum(A) <= S:
		Ans[qu] = 0
		continue
	ans = -1
	idx = None
	for i in range(N):
		a = A[i]
		k = br(AA, a + S)
		if ans < k:
			ans = k
			idx = i
		if AA[i] > S:
			break
	Ans[qu] = idx + 1
print('\n'.join(map(str, Ans)))


import sys, math
MOD = 10 ** 9 + 7

def skip(indx):
	(l, h) = (indx, n - 1)
	ans = 0
	while l <= h:
		m = (l + h) // 2
		if ps[m] - a[indx] <= s:
			ans = m
			l = m + 1
		else:
			h = m - 1
	return ans
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	ps = a[:]
	for i in range(1, n):
		ps[i] += ps[i - 1]
	if ps[-1] <= s:
		print(0)
		continue
	ans = [skip(i) for i in range(n)]
	if max(ans) == 0:
		print(0)
	else:
		print(ans.index(max(ans)) + 1)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	idx = 0
	for i in range(n):
		if a[i] > a[idx]:
			idx = i
		t -= a[i]
		if t < 0:
			break
	if t >= 0:
		idx = -1
	print(idx + 1)


class Bit:

	def __init__(self, a):
		self.a = a
		self.n = len(a)
		self.bit = [0] * (self.n + 1)
		for (i, x) in enumerate(a):
			self.update(i + 1, x)

	def update(self, x, val):
		while x <= self.n:
			self.bit[x] += val
			x += x & -x

	def query(self, x):
		sum = 0
		while x > 0:
			sum += self.bit[x]
			x -= x & -x
		return sum
for _ in range(int(input())):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		continue
	total = 0
	maxi = 0
	ind = 0
	for i in range(n):
		total += a[i]
		if a[i] > maxi and total - a[i] <= s:
			maxi = a[i]
			ind = i + 1
		if total - maxi <= s:
			continue
		else:
			break
	print(ind)


from math import sqrt, ceil

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
t = ii()
while t:
	t -= 1
	(n, s) = mi()
	a = li()
	f = 0
	b = []
	for i in range(n):
		s -= a[i]
		b.append(a[i])
		if s < 0:
			f = 1
			break
	if f == 1:
		if len(b) != 0:
			x = max(b)
			print(a.index(x) + 1)
		else:
			print('1')
	else:
		print('0')


for i in range(0, int(input())):
	(n, s) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if sum(l) <= s:
		print(0)
	else:
		sh = 0
		m = 0
		index = 0
		for i in range(0, len(l)):
			if sh >= s:
				break
			elif l[i] > m:
				sh = sh + m
				if sh > s:
					break
				else:
					m = l[i]
					index = i + 1
			else:
				sh = sh + l[i]
		print(index)


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	t = list(map(int, input().split()))
	p = 0
	for j in range(a):
		if t[j] > t[p]:
			p = j
		b -= t[j]
		if b < 0:
			break
	if b >= 0:
		p = -1
	print(p + 1)


T = int(input())
for _ in range(T):
	(n, s) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	tot = sum(arr)
	if tot <= s:
		print(0)
	else:
		hi = 0
		idx = 0
		tot = s
		cnt = 0
		for (i, x) in enumerate(arr):
			tmp = max(hi, x)
			tot -= x
			cnt += 1
			if tot + tmp < 0:
				break
			if x > hi:
				idx = i
				hi = x
		cnt2 = 0
		tot = s
		for (i, x) in enumerate(arr):
			tot -= x
			if tot < 0:
				cnt2 = i
				break
		if cnt > cnt2:
			print(idx + 1)
		else:
			print(0)


tt = int(input())
for i in range(tt):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	mx = 0
	sm = 0
	flag = False
	for i in range(n):
		mx = max(mx, a[i])
		sm += a[i]
		if sm > s:
			for j in range(n):
				if a[j] == mx:
					print(j + 1)
					flag = True
					break
		if flag:
			break
	if not flag:
		print(0)


t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) <= s:
		print(0)
		continue
	sm = 0
	mx = [0, -1]
	i = 0
	while i < n:
		x = a[i]
		smm = sm + x
		mxx = max(mx[0], x)
		if smm - mxx > s:
			break
		sm += x
		if x > mx[0]:
			mx = [x, i]
		i += 1
	print(mx[1] + 1)


def find_upper(lookup_array, item, start_point=0):
	for i in range(start_point, len(lookup_array)):
		if lookup_array[i] > item:
			return i
	return -1

def find_removable(verse_length, time_limit):
	sum_array = []
	summed = 0
	for i in verse_length:
		summed += i
		sum_array.append(summed)
	final_index = find_upper(sum_array, time_limit)
	if final_index == -1:
		return 0
	max_possible = final_index + 1
	max_index_remove = -1
	maxi = max(verse_length[:final_index + 1])
	new_index = find_upper(sum_array, time_limit + maxi)
	if new_index > max_possible or new_index == -1:
		return verse_length.index(maxi) + 1
	else:
		return 0
useless = int(input())
for i in range(useless):
	(n, time) = [int(i) for i in input().split()]
	verses = [int(i) for i in input().split()]
	print(find_removable(verses, time))


import sys

class BVerseForSanta:

	def solve(self):
		for _ in range(int(input())):
			(n, s) = [int(_) for _ in input().split()]
			a = [int(_) for _ in input().split()]
			if sum(a) <= s:
				print(0)
				continue
			part = 0
			ans = -1
			cur_max = -float('inf')
			cur_max_i = -1
			for i in range(n):
				part += a[i]
				if a[i] > cur_max:
					cur_max_i = i
				cur_max = max(cur_max, a[i])
				v = part - cur_max
				if v <= s:
					ans = cur_max_i
			print(ans + 1)
solver = BVerseForSanta()
input = sys.stdin.readline
solver.solve()


t = int(input())
from math import *
while t > 0:
	t -= 1
	(n, s) = map(int, input().split())
	a = [int(x) for x in input().split()]
	flag = 0
	maxi = -9
	z = 0
	for i in range(n):
		if a[i] > maxi:
			maxi = a[i]
		s -= a[i]
		if s < 0 and flag == 1:
			break
		elif s < 0 and flag == 0:
			s += maxi
			z = a.index(maxi)
			flag = 1
	if flag == 1:
		print(z + 1)
	else:
		print(0)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = 0
	summ = 0
	for i in range(n):
		if arr[i] > arr[ans]:
			ans = i
		summ += arr[i]
		if summ > s:
			break
	if summ <= s:
		print(0)
	else:
		print(ans + 1)


from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
mod2 = 998244353
INF = float('inf')

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

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

def inpln(n):
	return list((int(sys.stdin.readline()) for i in range(n)))
t = inp()
for i in range(t):
	(n, c) = inpl()
	a = inpl()
	if sum(a) <= c:
		print(0)
		continue
	su = 0
	mx = 0
	md = 1
	for i in range(n):
		su += a[i]
		if a[i] > mx:
			md = i + 1
			mx = a[i]
		if su > c:
			print(md)
			break


num_t = int(input())
for j in range(num_t):
	(n, s) = map(int, input().split())
	arr = [int(s) for s in input().split()]
	pref = [arr[0]]
	max_is = [0]
	for i in range(1, len(arr)):
		pref.append(pref[i - 1] + arr[i])
		max_is.append(i if arr[i] > arr[max_is[i - 1]] else max_is[i - 1])
	for i in range(len(pref) - 1, -1, -1):
		if pref[i] <= s:
			print(0)
			break
		if pref[i] - arr[max_is[i]] <= s:
			print(max_is[i] + 1)
			break


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, s) = li()
	l = li()
	su = 0
	currmax = -float('inf')
	i = 0
	d = {}
	while i < n:
		if s - l[i] >= 0:
			s -= l[i]
		else:
			break
		currmax = max(currmax, l[i])
		d[l[i]] = i
		i += 1
	if i == n:
		print(0)
		continue
	currlen = i
	currmax = max(currmax, l[i])
	s += currmax
	ans = currmax
	d[l[i]] = i
	i += 1
	while i < n:
		if s - l[i] >= 0:
			s -= l[i]
		else:
			break
		i += 1
	print(d[ans] + 1)


t = int(input())
for i in range(t):
	ns = list(map(int, input().split()))
	n = ns[0]
	s = ns[1]
	a = list(map(int, input().split()))
	i = 0
	m = a[0]
	m_i = 0
	max_s = 0
	while i < len(a) and a[i] + max_s <= s:
		max_s += a[i]
		if i + 1 < len(a) and m < a[i + 1]:
			m = a[i + 1]
			m_i = i + 1
		i += 1
	j = i
	if i < len(a):
		if m_i < i:
			max_s -= m
		while j < len(a):
			if j == m_i:
				j += 1
				continue
			if a[j] + max_s > s:
				break
			j += 1
		print(m_i + 1)
	else:
		print(0)


for _ in range(int(input())):
	(n, s) = map(int, input().split())
	arr = list(map(int, input().split()))
	flag = 0
	_s = sum(arr)
	if _s <= s:
		print(0)
		continue
	flag = 0
	temp = 0
	for i in range(n):
		temp += arr[i]
		if temp > s:
			flag = 1
			break
	if flag == 1:
		print(arr.index(max(arr[:i + 1])) + 1)
	else:
		print(0)


from sys import stdin

def read():
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, s, a)

def solve(n, s, a):
	mxi = 0
	total = 0
	for i in range(0, n):
		if total + a[i] > s:
			return i + 1 if a[i] > a[mxi] else mxi + 1
		else:
			total += a[i]
			if a[i] > a[mxi]:
				mxi = i
	return 0
for t in range(int(input())):
	result = solve(*read())
	print(result)

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


for t in range(int(input())):
	(n, s) = [int(a) for a in input().split()]
	nums = [int(a) for a in input().split()]
	index = 0
	c_max = 0
	s_max = 0
	n_max = 0
	for i in nums:
		if i > n_max:
			n_max = i
			index = c_max + 1
		if s_max + i > s:
			break
		s_max += i
		c_max += 1
	curr_s = -n_max
	curr_c = -1
	for i in nums:
		if curr_s + i > s:
			break
		curr_s += i
		curr_c += 1
	if curr_c <= c_max:
		print(0)
	else:
		print(index)


import sys
inf = int(10000000000.0)
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(n, s) = map(int, input().split())
	lis = list(map(int, input().split()))
	m = 0
	index = -1
	val = 0
	ans = 0
	for i in range(n):
		if m < lis[i]:
			m = lis[i]
			index = i
		val += lis[i]
		if val > s:
			if val - m <= s:
				ans = index + 1
			break
	print(ans)


from itertools import accumulate
t = int(input())
for _ in range(t):
	(n, s) = map(int, input().split())
	a = list(map(int, input().split()))
	total = list(accumulate(a))
	skip_index = [0] * n
	skip = a[0]
	for i in range(1, n):
		if a[i] > skip:
			skip_index[i] = i
			skip = a[i]
		else:
			skip_index[i] = skip_index[i - 1]
	ans = 0
	for i in range(n):
		if total[i] <= s:
			ans = 0
		elif total[i] - a[skip_index[i]] <= s:
			ans = skip_index[i] + 1
		else:
			break
	print(ans)


import os, sys, math
import collections
if os.path.exists('testing'):
	name = os.path.basename(__file__)
	if name.endswith('.py'):
		name = name[:-3]
	src = open(name + '.txt', encoding='utf8')
	input = src.readline

def solve():
	used_skip = False
	max_val = 0
	max_index = 0
	sum = 0
	for (e, v) in enumerate(xs):
		if not used_skip:
			if v > max_val:
				max_val = v
				max_index = e
		sum += v
		if sum > s:
			if used_skip:
				return max_index + 1
			if sum - max_val < s:
				sum -= max_val
				used_skip = True
	if used_skip:
		return max_index + 1
	return 0

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

def array_of_strings(q):
	return [input().strip() for _ in range(q)]

def integers():
	return map(int, input().strip().split())

def array_of_integers(q):
	return [tuple(map(int, input().strip().split())) for _ in range(q)]
(t,) = integers()
for _ in range(t):
	(n, s) = integers()
	xs = list(integers())
	res = solve()
	print(res)