# import io,os
# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from sys import stdin,stdout
input = stdin.readline
def im():
    return map(int,input().split())
def ii():
    return int(input())
def il():
    return list(map(int,input().split()))
def ins():
    return input()[:-1]


for _ in range(ii()):
    n,m = im()
    lis = il()
    inp = il()
    
    pre = []
    sm = 0
    for i in range(n):
        sm += lis[i]
        pre.append(sm)
    prev_pre = pre[:]
    pre.sort()
    
    ans = []
    for x in inp:
        if sum(lis)<=0 and pre[-1]<x:
            ans.append(-1)
            continue
        cnt=0
        if sum(lis)>0:
            while pre[-1]<x:
                x -= sum(lis)
                cnt += n
        l=0
        r=n-1
        while l<r:
            mid = (l+r)//2
            if pre[mid]<x:
                l = mid+1
            else:
                r = mid
        cnt+=prev_pre.index(pre[l])+1
        ans.append(cnt-1)
    print(*ans)