#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, q;
  cin >> n >> q;
  vector<long long> nums;
  vector<long long> pre;
  for (int i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    nums.push_back(temp);
    if (i == 0) {
      pre.push_back(temp);
    } else {
      pre.push_back(temp + pre[i - 1]);
    }
  }
  vector<long long> mx;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      mx.push_back(pre[i]);
    } else {
      mx.push_back(max(mx[i - 1], pre[i]));
    }
  }
  for (int i = 0; i < q; i++) {
    long long temp;
    cin >> temp;
    int lo = 0, hi = n;
    int ans = -1;
    while (lo < hi) {
      int mid = (lo + hi) / 2;
      if (mx[mid] >= temp) {
        hi = mid;
        ans = mid;
      } else {
        lo = mid + 1;
      }
    }
    if (ans != -1) {
      cout << ans << " ";
      continue;
    }
    if (pre[n - 1] <= 0) {
      cout << -1 << " ";
      continue;
    }
    long long div = (temp - pre[n - 1]) / pre[n - 1];
    if (temp % pre[n - 1] != 0) {
      div++;
    }
    temp -= div * pre[n - 1];
    long long cnt = div * n;
    lo = 0;
    hi = n;
    ans = -1;
    while (lo < hi) {
      int mid = (lo + hi) / 2;
      if (mx[mid] >= temp) {
        hi = mid;
        ans = mid;
      } else {
        lo = mid + 1;
      }
    }
    cnt += ans;
    cout << cnt << " ";
  }
  cout << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
