import java.io.*;
import java.util.*;

public class test {
   static class sort implements Comparator<long[]>
   {
	   	public int compare(long[] a,long[] b)
	   	{
	   		if(a[0]>b[0]) return 1;
	   		if(a[0]<b[0]) return -1;
	   		return 0;
	   	}
   }
   public static void print(Object o)
   {
   	 PrintWriter out = new PrintWriter(System.out);
	out.println(o.toString());
	out.flush();
   }
   public static int intIn(String st)
   {
   	  return Integer.parseInt(st);
   }
   
   public static long F(long x,long[] arr,long su)
   {
   	     long low=0l;long high=1000000000000000l;
   	     long max=10000000000000000l;
   	     long res=max;
   	     while(low<high)
   	     {
   	     	long mid = (low+high)/2;
   	     	long sum = (mid/(arr.length+0l))*(su) + arr[(int)(mid%(arr.length+0l))];
   	     	if(sum>x)
   	     	{
   	     		high=mid-1;
   	     	}
   	     	else if(sum<x)
   	     	{
   	     		low=mid+1;
   	     	}
   	     	else
   	     	{
   	     		res=Math.min(res,mid);
   	     		high=mid-1;
   	     	}
   	     }
   	     long mid=low;
   	     long sum = (mid/(arr.length+0l))*(su) + arr[(int)(mid%(arr.length+0l))];
   	     if(sum==x) res=Math.min(res,mid);
   	     if(res==max) return -1l;
   	     return res;
   }
    
	public static void main (String[] args) throws Exception {
        
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        
		int y=Integer.parseInt(bf.readLine());
		
		for(int h=0;h<y;h++)
		{
		    String[] xl=(bf.readLine()).split(" ");//int i=0;
            int a,b,m,n;//long ans=0l;
            n=Integer.parseInt(xl[0]);boolean bol=false;
            a=Integer.parseInt(xl[1]);
            xl = bf.readLine().split(" ");
           long[] pre=new long[n];
             long sum=0l;
             Map<Long,Integer> set=new HashMap<>();
            for(int o=0;o<n;o++)
		    {
		    	long u =Long.parseLong(xl[o]);
		    	sum += (u);
		    	pre[o]=sum;
		    	if(!set.containsKey(sum))
		    	set.put(sum,o);
		         
		    }
		    xl = bf.readLine().split(" ");
           
             //long[] q=new long[a];
            for(int o=0;o<a;o++)
		    {
		    	long u =Long.parseLong(xl[o]);
		    	if(sum<=0)
		    	{
		    		if(set.containsKey(u))
		    		{
		    			System.out.print(set.get(u)+" ");
		    		}
		    		else
		    		{
		    			System.out.print(-1+" ");
		    		}
		    	}
		    	else
		    	{
		    		
		    		//else
		    		{
		    			long res = F(u,pre,sum);
		    			System.out.print(res+" ");
		    		}
		    		
		    	}
		         
		    }
		    System.out.println("");
		    
		    
		    
		    
		    
		    
            
            
            
		}
	}
}
/*

5
1 2 2 3
1 -1 2 3 -1

*/


