#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 5;
void solve() {
  long long n, q;
  cin >> n >> q;
  long long ar[n];
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
    if (i > 0) ar[i] += ar[i - 1];
  }
  for (long long i = 1; i < n; i++) ar[i] = max(ar[i - 1], ar[i]);
  while (q--) {
    long long reqSum;
    cin >> reqSum;
    if (reqSum > ar[n - 1] && ar[n - 1] <= 0) {
      cout << "-1 ";
      continue;
    }
    if (reqSum <= ar[n - 1]) {
      long long idx = lower_bound(ar, ar + n, reqSum) - ar;
      cout << idx << " ";
      continue;
    }
    long long time_taken = (reqSum / ar[n - 1]) * n;
    time_taken--;
    reqSum %= ar[n - 1];
    if (reqSum == 0) {
      cout << time_taken << " ";
      continue;
    }
    long long idx = lower_bound(ar, ar + n, reqSum) - ar;
    time_taken += idx;
    cout << time_taken + 1 << " ";
  }
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
