N = int(input())

for i in range(N):
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    x = list(map(int,input().split()))
    for each in x:
        ret = 0
        cnt = 0
        while True:
            ret += a[(n+cnt)%n]
            if ret == each:
                print(cnt,end=' ')
                break
            else:
                cnt += 1
                if abs(ret-each)>=abs(each):
                    print('-1',end=' ')
                    break
    print()
