#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 1; i < n; ++i) a[i] += a[i - 1];
    for (int j = 0; j < k; ++j) {
      unsigned int res = 4e9;
      int val;
      cin >> val;
      for (unsigned int i = 0; i < n; ++i) {
        int tmp = val - a[i];
        if (tmp <= 0) {
          res = min(res, i);
        } else {
          unsigned int round = ceil(1.0 * tmp / a[n - 1]);
          if (round > 0) res = min(res, round * n + i);
        }
      }
      if (res != 4e9)
        cout << res << " ";
      else
        cout << -1 << " ";
    }
    cout << endl;
  }
  return 0;
}
