test=int(input())
while test>0:
    test-=1
    row=input()
    row=row.split(" ")
    n=int(row[0])
    m=int(row[1])
    a=[""]*n
    at=[""]*n
    x=[""]*m
    pos=[""]*n
    row=input()
    row=row.split(" ")
    cnt=-1
    su=0
    for i in range(0,n):
        at[i]=int(row[i])
        su+=at[i]
        if i==0 or (a[cnt]<su):
            cnt+=1
            a[cnt]=su
            pos[cnt]=i
    row=input()
    row=row.split(" ")
    for i in range(0,m):
        x[i]=int(row[i])
    for i in range(0,m):
        e=""
        if i==m-1: e="\n"
        else: e=" "
        if su<=0 and a[cnt]<x[i]:
            print(-1,end=e)
        else:
            if x[i]<=a[cnt]: seg=0
            else: seg=int((x[i]-su-1)/su)+1
            x[i]-=su*seg
            l=0
            r=cnt
            res=-1
            while l<=r:
                mid=int((l+r)/2)
                if a[mid]>=x[i]:
                    res=pos[mid]
                    r=mid-1
                else:
                    l=mid+1
            print(res+seg*n,end=e)


