#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
vector<long long> A, P, mi, ma;
int N, Q;
int first_neg(long long x) {
  int l = 0, r = N;
  while (l < r) {
    int m = (l + r) / 2;
    if (mi[m] <= x)
      r = m;
    else
      l = m + 1;
  }
  return l;
}
int first_pos(long long x) {
  int l = 0, r = N;
  while (l < r) {
    int m = (l + r) / 2;
    if (ma[m] >= x)
      r = m;
    else
      l = m + 1;
  }
  return l;
}
void test_case() {
  cin >> N >> Q;
  A.resize(N);
  for (auto& qw : (A)) cin >> qw;
  ;
  P = A;
  for (int i = 1; i < N; i++) P[i] += P[i - 1];
  mi = P;
  ma = P;
  for (int i = 1; i < N; i++) mi[i] = min(mi[i], mi[i - 1]);
  for (int i = 1; i < N; i++) ma[i] = max(ma[i], ma[i - 1]);
  while (Q--) {
    int x;
    cin >> x;
    if (x <= ma.back()) {
      cout << first_pos(x) << " ";
    } else {
      if (P.back() == 0) {
        cout << -1 << " ";
      } else if (P.back() > 0) {
        int l = 0, r = INF;
        while (l < r) {
          int m = (l + r) / 2;
          long long val = x - m * P.back();
          if (val <= ma.back())
            r = m;
          else
            l = m + 1;
        }
        cout << l * N + first_pos(x - l * P.back()) << " ";
      } else {
        cout << -1 << " ";
      }
    }
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tt = 1;
  cin >> tt;
  while (tt--) {
    test_case();
  }
  return 0;
}
