import javax.swing.plaf.synth.SynthUI;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int n = 0;
        while(n<N) {
            int k1= sc.nextInt();
            int[] a=new int[k1];
            int k2=sc.nextInt();
            int[] b=new int[k2];
            int i=0;
            for(i=0;i<k1;i++){
                a[i]= sc.nextInt();
            }
            for(i=0;i<k2;i++){
                b[i]= sc.nextInt();
            }
            int max=0,temp=0,sum=0,min=1000000000;
            for(i=0;i<k1;i++){
                temp+=a[i];
                max=Math.max(temp,max);
                min=Math.min(temp,min);
                sum+=a[i];
            }
            for(int k=0;k<k2;k++){
                int ans=0;
                if((sum<=0&&max<b[k])||(min>b[k]&&sum>=0)){
                    ans=-1;
                    if(k!=k2-1)
                    System.out.print(ans+" ");
                    else {
                        System.out.print(ans);
                        System.out.println();
                    }
                }
                else {
                    int s=a[0];
                    int t=1;
                    while (s<b[k]){
                        s+=a[t];
                        if(t==k1-1){
                            t=0;
                        }else t++;
                        ans++;
                    }
                    if(k!=k2-1)
                        System.out.print(ans+" ");
                    else {
                        System.out.print(ans);
                        System.out.println();
                    }
                }

            }



        n++;

        }

    }

}


 		 		 	  	  				  	 	  	 					