import sys
from collections import deque
import bisect
input_ = lambda: sys.stdin.readline().strip("\r\n")
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
li = lambda : list(input_())
pr = lambda x : print(x)
f = lambda : sys.stdout.flush()

for _ in range (ii()) :
    n,m = il()
    a = il()
    b = il()

    p = -float('inf')
    x = 0

    c = []

    for i in range (n) :
        x += a[i]
        c.append(max(x,p))
        p = max(x,p)

    #print(c)
    ans = []

    for i in b :
        l = 0

        if (p > 0) :
            l1 = max(0,(i+x-p-1)//p)
         #   print(l1)
            l = l1*n
            i -= l1*p
        #print(i,x)
        if (i > p) :
            ans.append('-1')
        else :
            lef = bisect.bisect_left(c,i)
            #print(lef)
            ans.append(str(l+lef))

    print(*ans)
        
