from bisect import bisect_left
from math import ceil
def floppy(arr,q):
	s=sum(arr)
	pref=[arr[0]]
	for i in arr[1:]:
		pref.append(pref[-1]+i)
	n=len(arr)
	for i in q:
		#csum*x +prefsum>=q
		ans=float("inf")
		for pos in range(len(pref)):
			if s:
				x=ceil((i-pref[pos])/s)
				if x>=0:
					ans=min(ans,x*n+pos)
			else:
				if pref[pos]>=i:
					ans=min(ans,pos)
		print([ans,-1][ans==float("inf")],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))