def Csum(a):
    b,c=[],0
    for i in range(len(a)):
        c+=a[i]
        b.append(c)
    return b

t=int(input())
for _ in range(t):
    n,m=map(int, input().split())
    a=list(map(int, input().split()))
    c=Csum(a)
    x=list(map(int, input().split()))
    b=max(c)
    d=c[-1]
    ans=[]
    for i in x:
        if d<=0 and b<i:
            ans.append(-1)
            continue
        elif d==0:
            s=0
            for j in range(n):
                s += a[j]
                if s >= i:
                    ans.append(j)
                    break
        else:
            e=(i-b-1)//d+1
            s=d*e
            for j in range(n):
                s+=a[j]
                if s>=i:
                    ans.append(e*n+j)
                    break

    print(*ans)
