#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vec;
int n, m;
int get(int x) {
  int l = 0, r = n - 1, ans = n;
  for (int i = 0; i < 22; ++i) {
    int mid = l + r >> 1;
    if (vec[mid].first >= x) {
      ans = mid;
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  return ans == n ? n : vec[ans].second;
}
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    vec.clear();
    scanf("%d %d", &n, &m);
    auto pref = 0LL;
    for (int i = 0, x; i < n; ++i) {
      scanf("%d", &x);
      pref += 1LL * x;
      vec.emplace_back(pref, i);
    }
    sort(vec.begin(), vec.end());
    while (m--) {
      int x;
      scanf("%d", &x);
      if (x > vec.back().first && pref <= 0) {
        printf("-1 ");
        continue;
      }
      int pos = get(x);
      if (pos == n) {
        long long tt = 1LL * (x / pref) * n;
        if (x % pref == 0) {
          --tt;
        }
        x %= pref;
        printf("%lld ", tt + get(x));
      } else {
        printf("%d ", pos);
      }
    }
    puts("");
  }
  return 0;
}
