var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var m = read.split(" ").map(function(x) { return parseInt(x); })[1];
    var a = readline().split(" ").map(function(x) { return parseInt(x); });
    var x = readline().split(" ").map(function(x) { return parseInt(x); });
    
    var step = 0;
    var b = [];
    for(var i = 0; i < n; i++) {
        step += a[i];
        b[i] = step;
    }
    
    var resultArr = [];
    for(var i = 0; i < m; i++) {
        var result = -1;
        for(var j = 0; j < n; j++) {
            if(a[j] == 0) continue;
            if(x[i] <= b[j] && x[i] * b[j] > 0) {
                result = j;
                break;
            }
            if(step == 0) {
                result = -1;
                break;
            }
            if((x[i] * b[j]) > 0 || (x[i] - b[j]) / step >= 0)
                if(result == -1 || Math.ceil((x[i] - b[j]) / step) * n < result)
                    result = j + Math.ceil((x[i] - b[j]) / step) * n;
        }
        result = result < -1 ? -1 : result;
        if(result == 0 && x[i] > a[0]) result = -1;
        resultArr.push(result);
    }
    
    write(resultArr.join(" ") + "\n");
}