#include <bits/stdc++.h>
using namespace std;
void solve(long long int arr[], int n, int m) {
  vector<long long int> maxPrefixSum(n);
  long long int currentSum = 0;
  for (int i = 0; i < n; i++) {
    currentSum += arr[i];
    maxPrefixSum[i] =
        (i == 0) ? currentSum : max(currentSum, maxPrefixSum[i - 1]);
  }
  long long int totalSum = currentSum;
  while (m--) {
    long long int x;
    cin >> x;
    if (totalSum <= 0) {
      if (x > maxPrefixSum.back()) {
        cout << -1 << " ";
        continue;
      }
      long long int ans =
          lower_bound(maxPrefixSum.begin(), maxPrefixSum.end(), x) -
          maxPrefixSum.begin();
      cout << max(0LL, ans) << " ";
      continue;
    }
    long long int y = max(0LL, x - maxPrefixSum.back());
    long long int fullIterations = (y - totalSum + 1) / totalSum;
    long long int remainingSum = x - totalSum * fullIterations;
    long long int index =
        lower_bound(maxPrefixSum.begin(), maxPrefixSum.end(), remainingSum) -
        maxPrefixSum.begin();
    long long int ans = n * fullIterations + index;
    cout << max(0LL, ans) << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    long long int arr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    solve(arr, n, m);
  }
}
