import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner (System.in);
        int tests = scn.nextInt();
        int[][]returnAns = new int[tests][];
        int[] storeM = new int[tests];

        for(int i = 0; i< tests ; i++)
        {
            int n = scn.nextInt();
            int m = scn.nextInt();
            storeM[i]=m;
            int[] array = new int[n];
            int[] x = new int[n];
            returnAns[i]= new int[m];
            for(int j = 0 ; j<n ; j++)
                array[j]= scn.nextInt();
            for(int t = 0 ; t<n ; t++)
                x[t]=scn.nextInt();

            for(int b= 0 ; b<m ; b++) {
                int z = 0;
                int sum = x[0];
                int counter = 0;
                int checkInfinity = 0;
                for (int c = 0; c < n; c++)
                    checkInfinity += array[c];

                if (checkInfinity > 0 && x[b] > 0 || (checkInfinity < 0 && x[b] < 0)) {
                    while (sum <=x[b]) {
                        counter++;
                        sum = sum + array[z];
                        z++;
                        if (z >= n)
                            z = 0;

                    }
                        if(counter!=1 || counter!=0)
                        returnAns[i][b] = (counter-1);
                        else
                            returnAns[i][b]=counter;

                }
                else
                    returnAns[i][b]=-1;
            }

        }

        for(int i = 0 ; i< tests ; i++)
        {
            for(int j = 0 ; j<storeM[i] ; j++)
                System.out.print(returnAns[i][j]+ " ");
            System.out.println();
        }
    }
}