#include <bits/stdc++.h>
using namespace std;
long long pow(long long x, long long y, long long mod) {
  long long temp;
  if (y == 0) return 1;
  temp = (pow(x, y / 2, mod)) % mod;
  if (y % 2 == 0)
    return (temp * temp) % mod;
  else
    return (((x * temp) % mod) * temp) % mod;
}
void solve(long long tno) {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  partial_sum(a.begin(), a.end(), a.begin());
  map<long long, long long> y;
  long long maxElem = LLONG_MIN;
  y[a[0]] = 0;
  long long prevMax = a[0];
  for (long long i = 1; i < n; i++) {
    if (a[i] > prevMax && y.count(a[i]) == 0) {
      y[a[i]] = i;
      prevMax = a[i];
      maxElem = max(maxElem, a[i]);
    }
  }
  for (long long i = 0; i < m; i++) {
    long long x;
    cin >> x;
    if (x <= maxElem) {
      cout << y.lower_bound(x)->second << ' ';
      continue;
    } else {
      if (a[n - 1] <= 0) {
        cout << -1 << ' ';
        continue;
      }
      long long ans = (ceil((x - maxElem) * 1.0 / a[n - 1])) * n;
      x = x - ((ans / n) * a[n - 1]);
      ans += y.lower_bound(x)->second;
      cout << ans << ' ';
    }
  }
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  for (long long i = 1; i <= t; i++) solve(i);
}
