
import java.util.Scanner;

public class CF1490G {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for (int i = 0; i < t; i++) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] arr = new int[n];
			int[] x = new int[m];
			for (int j = 0; j < n; j++)
				arr[j] = sc.nextInt();
			for (int j = 0; j < m; j++)
				x[j] = sc.nextInt();
			
			for (int j = 0; j < m; j++) {
				int cnt=-1,sum=0,k=0;
				while(true) {
					if(sum>=x[j]) {
						System.out.println(cnt);
						break;
					}
					sum+=arr[k%(n)];
					if((k==n-1)&&(sum<0||sum<x[j])) {
						System.out.println("-1");
						break;
					}
					k++;cnt++;
				}
			}
				

		}
	}

}
