#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int result = 1;
  while (b > 0) {
    int lastbit = (b & 1);
    if (lastbit) {
      result = (result * a);
    }
    a = (a * a);
    b = b >> 1;
  }
  return result;
}
long long int power2(long long int a, long long int b, long long int p) {
  long long int result = 1;
  while (b > 0) {
    int lastbit = (b & 1);
    if (lastbit) {
      result = (result * a) % p;
    }
    a = (a * a) % p;
    b = b >> 1;
  }
  return result % p;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<long long int> SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  vector<long long int> v;
  for (int p = 2; p <= n; p++)
    if (prime[p]) v.push_back(p);
  return v;
}
vector<long long int> SmallestPrimeFactors(int n) {
  vector<long long int> spf(n + 1, 0);
  spf[1] = 1;
  for (int i = 2; i <= n; i++) {
    spf[i] = i;
  }
  for (int i = 4; i <= n; i += 2) {
    spf[i] = 2;
  }
  for (int i = 3; (i * i) <= n; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < 1000001; j += i) {
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
  return spf;
}
void shortest(map<int, vector<pair<int, long long int>>> m, int src, int n,
              long long int *dist) {
  bool visited[n + 1];
  set<pair<long long int, int>> s;
  for (int i = 0; i <= n; i++) {
    dist[i] = -1;
    visited[i] = false;
  }
  s.insert(make_pair(0ll, src));
  dist[src] = 0;
  while (!s.empty()) {
    auto t = s.begin();
    long long int dis = (*t).first;
    int u = (*t).second;
    s.erase(t);
    if (visited[u]) {
      continue;
    }
    visited[u] = true;
    for (auto tt : m[u]) {
      int v = tt.first;
      long long int w = tt.second;
      if (!visited[v]) {
        if (dist[v] != -1 && dist[v] > dis + w) {
          s.erase(make_pair(dist[v], v));
          dist[v] = dis + w;
          s.insert(make_pair(dist[v], v));
        } else if (dist[v] == -1) {
          dist[v] = dis + w;
          s.insert(make_pair(dist[v], v));
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int ttttt = 1;
  cin >> ttttt;
  for (int tttt = 1; tttt <= ttttt; tttt++) {
    int n, q;
    cin >> n >> q;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    map<long long int, int> m;
    long long int pre = 0;
    set<long long int> s;
    long long int maxi = LONG_LONG_MIN;
    for (int i = 0; i < n; i++) {
      pre += a[i];
      if (m.find(pre) == m.end() && pre > maxi) {
        m[pre] = i;
        s.insert(pre);
        maxi = max(maxi, pre);
      }
    }
    while (q--) {
      long long int x;
      cin >> x;
      if (x <= maxi) {
        auto t = lower_bound((s).begin(), (s).end(), x);
        long long int tt = m[(*t)];
        cout << tt;
      } else {
        if (maxi <= 0) {
          cout << -1;
        } else if (pre <= 0) {
          cout << -1;
        } else {
          long long int t = x - maxi;
          long long int tt = t / pre;
          if (t % pre) {
            long long int ttt = t - pre * (tt + 1);
            auto it = s.lower_bound(ttt);
            long long int ans = n * (tt + 1) + m[(*it)];
            cout << ans;
          } else {
            long long int ans = n * tt + m[maxi];
            cout << ans;
          }
        }
      }
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}
