#include <bits/stdc++.h>
using namespace std;
using pi = pair<long long, long long>;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const long long minf = 0xc0c0c0c0c0c0c0c0;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long TC;
  cin >> TC;
  long long A[200200];
  for (long long tc = 1; tc <= TC; tc++) {
    long long n, m;
    cin >> n >> m;
    for (long long i = 1; i <= n; i++) cin >> A[i];
    long long sum = 0;
    vector<pi> v;
    for (long long i = 1; i <= n; i++) {
      v.push_back(make_pair(sum += A[i], i));
    }
    sort((v).begin(), (v).end());
    while (m--) {
      long long q;
      cin >> q;
      if (q > v.back().first) {
        if (sum <= 0) {
          cout << -1 << ' ';
          continue;
        }
        long long res = (q - 1) / sum * n - 1;
        auto it = lower_bound((v).begin(), (v).end(),
                              make_pair((q - 1) % sum + 1, 0LL));
        res += it->second;
        cout << res << ' ';
        continue;
      }
      auto it = lower_bound((v).begin(), (v).end(), make_pair(q, 0LL));
      cout << it->second - 1 << ' ';
    }
    cout << '\n';
  }
  return 0;
}
