#include <bits/stdc++.h>
using namespace std;
void jabru() {
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  vector<long long> v(n);
  long long sum = 0;
  set<long long> s;
  map<long long, long long> m;
  long long mx = LLONG_MIN;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
    if (sum > 0) {
      s.insert(sum);
      if (m[sum] == 0) {
        m[sum] = i + 1;
      }
      mx = max(mx, sum);
    }
  }
  for (long long i = 0; i < q; i++) {
    long long x;
    cin >> x;
    long long ans = -1;
    long long uu = 0;
    bool flag = 0;
    if (x > mx && sum > 0) {
      uu = x / sum;
      x %= sum;
      ans += uu * n;
      if (x == 0) {
        flag = 1;
      }
    }
    auto it = s.lower_bound(x);
    if (flag) {
      cout << (ans == -1 ? 0 : ans) << " ";
    } else if (s.size() == 0) {
      cout << -1 << " ";
    } else if (x > mx) {
      cout << -1 << " ";
    } else if (it == s.end()) {
      cout << -1 << " ";
    } else {
      long long val = *it;
      ans += m[val];
      cout << (ans == -1 ? 0 : ans) << " ";
    }
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    jabru();
  }
  return 0;
}
