for i in range(int(input())):
    n,m=list(map(int,input().split()))
    a=list(map(int,input().split()))
    x=list(map(int,input().split()))
    b=[]
    e=0
    for j in range(n):
        e+=a[j]
        b.append([e,j])
    b.sort()
    d=b[-1][0]
    y=[]
    for j in range(m):
        x1=x[j]
        if d<=0:
            y.append(-1)
        elif d>=x1:
            g=n/2
            h=int(g)
            while int(g)>0:
                if b[h][0]<x1:
                    if h+round(g/2)<n:
                        h+=round(g/2)
                    else:
                        h+=int(g/2)
                else:
                    if h-round(g/2)>0:
                        h-=round(g/2)
                    else:
                        h-=int(g/2)
                g/=2
            h-=1
            while b[h][0]==b[h+1][0] and h>0:
                h-=1
            y.append(b[h+1][1])
        else:
            if e<=0:
                y.append(-1)
            else:
                f=(x1-1)//e*n
                x1%=e
                g=n/2
                h=round(g)
                while int(g)>0:
                    if b[h][0]<x1:
                        if h+round(g/2)<n:
                            h+=round(g/2)
                        else:
                            h+=int(g/2)
                    else:
                        if h-round(g/2)>0:
                            h-=round(g/2)
                        else:
                            h-=int(g/2)
                    g/=2
                h-=1
                while b[h][0]==b[h+1][0] and h>0:
                    h-=1
                y.append(f+b[h+1][1])
    print(*y)