from bisect import bisect_left
from sys import stdin
input=stdin.readline
def floppy(arr,q):
	ans=[arr[0]]
	i=1
	l=len(arr)
	pos={arr[0]:1}
	while len(ans)<(l*100)//2+300:
		if i<len(arr):
			ans.append(ans[-1]+arr[i])
			pos[ans[-1]]=min(pos.get(ans[-1],float("inf")),len(ans))
		else:
			i=0
			ans.append(ans[-1]+arr[i])
			pos[ans[-1]]=min(pos.get(ans[-1],float("inf")),len(ans))
		i+=1
	ans=sorted(ans)

	n=len(ans)
	for val in q:
		pt=bisect_left(ans,val)
		if pt>=n:
			print(-1,end=" ")
		else:
			t=ans[pt:]
			mini=min(t,key=lambda s:pos[s])
			print(pos[mini]-1,end=" ")
	return ""
for i in range(int(input())):
	a=input()
	lst=list(map(int,input().strip().split()))
	lst2=list(map(int,input().strip().split()))
	print(floppy(lst,lst2))