from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf,log2
import bisect
import sys
import copy
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
from math import ceil
import heapq



for i in range(int(input())):
    n,m=get_ints()
    a=get_array()
    x=get_array()
    sumi=a[0]
    c=[]
    c.append([a[0],0])
    for i in range(1,n):
        sumi+=a[i]
        c.append([sumi,i])
    c.sort()
    a1,a2=[],[]
    for i in range(len(c)):
        a1.append(c[i][0])
        a2.append(c[i][1])
    ##mini=inf
    fin=[]
    for i in range(m):
        l=0
        r=(10**9)+1
        ##flag=0
        ans=bisect.bisect_right(a1,x[i]-1)
        ##fin=[]
        if ans==n and sumi<=0:
            fin.append(-1)
        else:
            mini = inf
            while (l<=r):
                mid=(l+r)//2
                lim=x[i]-(sumi*mid)
                ans=bisect.bisect_right(a1,lim-1)
                if ans!=n:
                    mini=min(mini,(mid*n)+a2[ans]+1)
                    ##flag=1
                    r=mid-1
                else:
                    l=mid+1

            fin.append(mini-1)
    print(*fin)




