#include <bits/stdc++.h>
using namespace std;
int d[400005];
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    long long mx = numeric_limits<long long>::min();
    long long sum = 0;
    vector<pair<long long, int>> v(n);
    for (int i = 0; i < n; i++) {
      cin >> d[i];
      sum += d[i];
      mx = max(mx, sum);
      v[i].first = sum;
      v[i].second = i;
    }
    sort(v.begin(), v.end());
    while (m--) {
      long long x;
      cin >> x;
      if (sum <= 0 && mx < x) {
        cout << "-1 ";
        continue;
      } else if (sum <= 0 || mx >= x) {
        auto lower = *lower_bound(v.begin(), v.end(), make_pair(x, 0));
        cout << lower.second << " ";
      } else {
        auto k = x;
        int m = n;
        while (k > mx) {
          k -= sum;
          m++;
        }
        auto lower = *lower_bound(v.begin(), v.end(), make_pair(k, 0));
        cout << lower.second + x * m << " ";
      }
    }
    cout << "\n";
  }
}
