//package sycamore;

import java.util.Scanner;

/*
3
3 3
1 -3 4
1 5 2
2 2
-2 0
1 2
2 2
0 1
1 2
 */

public class CF1490G {
	public static void main(String[] args) {
		int t, n, m, a[], x, i, secs, aSum;
		Scanner sc = new Scanner(System.in);
		t = sc.nextInt();
		while(t-- > 0) {
			n = sc.nextInt();
			m = sc.nextInt();
			aSum = 0;
			a = new int[n];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
				aSum += a[i];
			}
			for(i = 0; i < m; i++) {
				x = sc.nextInt();
				secs=0;
				if(x <= a[0]) System.out.print(0+" ");
				else if(aSum < 1) System.out.print(-1+" ");
				else {
					int revs = x / aSum;
					secs = n * revs - 1;
					if(x % aSum != 0) {
						x = x % aSum;
						for(int ai : a) {
							if(x > 0) {
								x = x - ai;
								secs++;
							}else break;
						}
					}
					System.out.print(secs+" ");
				}
			}
			System.out.println();
		}
	}
}
