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.

Difficulty: EASY

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 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()


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)


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')


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')


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)


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()


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)


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)


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
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)


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 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)


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):
	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


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())
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)


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)


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)


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 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 = [*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))


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)


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)


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.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)


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


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)


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


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)


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)


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)


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))


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


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)


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)


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)


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 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)


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)


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)


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 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()


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))


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())):
	(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)


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)


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)


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 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())
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)


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)


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)


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)


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)


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()


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


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()


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 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]


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)


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')


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)


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


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)


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)


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()


(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


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())
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) = 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) = 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)


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)


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)


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)


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)


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)


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)


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))


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)


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)))


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)


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


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')


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)