#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    long long sum = 0, best = 0;
    vector<pair<long long, int>> pref;
    pref.push_back({0, 0});
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      sum += a[i];
      if (sum > best) {
        best = sum;
        pref.push_back({best, i + 1});
      }
    }
    while (m--) {
      long long x;
      cin >> x;
      if (sum <= 0 && pref.back().first < x) {
        cout << "-1 ";
        continue;
      }
      int need = (sum ? (x - pref.back().first + sum - 1) / sum : 0);
      cout << need * n +
                  (*lower_bound(pref.begin(), pref.end(),
                                make_pair(x - sum * need, 0)))
                      .second -
                  1
           << " ";
    }
    cout << "\n";
  }
  return 0;
}
