import java.io.*;

public class OldFloppyDrive {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = Integer.parseInt(br.readLine());

        for (int testcase = 0; testcase < t; testcase++) {
            String[] input = br.readLine().trim().split(" ");
            int n = Integer.parseInt(input[0]);
            int m = Integer.parseInt(input[1]);

            int[] arr = new int[n];
            input = br.readLine().trim().split(" ");
            int max = 0;
            int totalSum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(input[i]);
                totalSum += arr[i];
                max = Math.max(totalSum, max);
                arr[i] = max;
            }
            int[] queries = new int[m];
            input = br.readLine().trim().split(" ");
            for (int i = 0; i < m; i++) {
                queries[i] = Integer.parseInt(input[i]);
            }

            for (int q : queries) {
                if (q > max && totalSum <= 0) {
                    bw.write("-1 ");
                } else {
                    int seconds = Math.max(0, (int) Math.ceil(((double) q - max) / totalSum)); // currently just number of cycles before final
                    int current = totalSum * seconds;
                    seconds *= n;
                    seconds += binSearch(arr, q - current);
                    bw.write(seconds - 1 + " ");
                }
            }
            bw.write("\n");
        }
        br.close();
        bw.close();
    }

    private static int binSearch(int[] arr, int t) {
        int l = 0;
        int h = arr.length;
        while (l < h) {
            int mid = (l + h) / 2;
            if (arr[mid] < t) {
                l = mid + 1;
            } else {
                h = mid;
            }
        }
        return l + 1;
    }

}
