#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
long long n, m, maxs, sum;
long long arr[N];
signed main(void) {
  long long T;
  scanf("%lld", &T);
  while (T--) {
    scanf("%lld%lld", &n, &m);
    for (long long i = 1; i <= n; i++) scanf("%lld", &arr[i]);
    maxs = -1;
    sum = 0;
    for (long long i = 1; i <= n; i++) {
      sum += arr[i];
      maxs = max(maxs, sum);
    }
    for (long long i = 1; i <= m; i++) {
      long long x;
      scanf("%lld", &x);
      if (maxs < x && sum <= 0) {
        printf("-1 ");
        continue;
      } else if (sum <= 0) {
        if (maxs >= x) {
          long long tmp = 0;
          for (long long j = 1; j <= n; j++) {
            tmp += arr[i];
            if (tmp >= x) {
              printf("%d ", j);
              break;
            }
          }
        }
      } else {
        long long l = 0, r = N, round;
        while (l <= r) {
          long long mid = (l + r) >> 1;
          if (1ll * mid * sum + maxs >= x) {
            r = mid - 1;
            round = mid;
          } else
            l = mid + 1;
        }
        long long base = round * n;
        long long now = 1ll * sum * round, tmp = 0;
        for (long long j = 1; j <= n; j++) {
          tmp += arr[j];
          if (tmp + now >= x) {
            printf("%lld ", base + j - 1);
            break;
          }
        }
      }
    }
    puts("");
  }
  return 0;
}
