Timur has $n$ candies. The $i$-th candy has a quantity of sugar equal to $a_i$. So, by eating the $i$-th candy, Timur consumes a quantity of sugar equal to $a_i$.

Timur will ask you $q$ queries regarding his candies. For the $j$-th query you have to answer what is the minimum number of candies he needs to eat in order to reach a quantity of sugar greater than or equal to $x_j$ or print -1 if it's not possible to obtain such a quantity. In other words, you should print the minimum possible $k$ such that after eating $k$ candies, Timur consumes a quantity of sugar of at least $x_j$ or say that no possible $k$ exists.

Note that he can't eat the same candy twice and queries are independent of each other (Timur can use the same candy in different queries).


-----Input-----

The first line of input contains a single integer $t$ ($1 \leq t \leq 1000$)  — the number of test cases. The description of test cases follows.

The first line contains $2$ integers $n$ and $q$ ($1 \leq n, q \leq 1.5\cdot10^5$) — the number of candies Timur has and the number of queries you have to print an answer for respectively.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \leq a_i \leq 10^4$) — the quantity of sugar in each of the candies respectively.

Then $q$ lines follow.

Each of the next $q$ lines contains a single integer $x_j$ ($1 \leq x_j \leq 2 \cdot 10^9$) – the quantity Timur wants to reach for the given query.

It is guaranteed that the sum of $n$ and the sum of $q$ over all test cases do not exceed $1.5 \cdot 10^5$.


-----Output-----

For each test case output $q$ lines. For the $j$-th line output the number of candies Timur needs to eat in order to reach a quantity of sugar greater than or equal to $x_j$ or print -1 if it's not possible to obtain such a quantity.


-----Examples-----

Input
3
8 7
4 3 3 1 1 4 5 9
1
10
50
14
15
22
30
4 1
1 2 3 4
3
1 2
5
4
6
Output
1
2
-1
2
3
4
8
1
1
-1


-----Note-----

For the first test case:

For the first query, Timur can eat any candy, and he will reach the desired quantity.

For the second query, Timur can reach a quantity of at least $10$ by eating the $7$-th and the $8$-th candies, thus consuming a quantity of sugar equal to $14$.

For the third query, there is no possible answer.

For the fourth query, Timur can reach a quantity of at least $14$ by eating the $7$-th and the $8$-th candies, thus consuming a quantity of sugar equal to $14$.

For the second test case:

For the only query of the second test case, we can choose the third candy from which Timur receives exactly $3$ sugar. It's also possible to obtain the same answer by choosing the fourth candy.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Greedy algorithms


Solutions:
from math import inf, gcd, log, log2, floor, ceil, sqrt
from collections import Counter, defaultdict
from heapq import heappush, heappop, heapify
from functools import lru_cache
from itertools import accumulate
import bisect
import sys
DIRS = [[1, 0], [0, 1], [0, -1], [-1, 0], [-1, -1], [1, 1], [-1, 1], [1, -1]]
MOD = 10 ** 9 + 7
input = sys.stdin.readline
t = int(input())

def solve():
	(n, q) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	qa = []
	for _ in range(q):
		qa.append(int(input()))
	a.sort(reverse=True)
	pfs = list(accumulate(a, initial=0))
	ans = []
	for x in qa:
		idx = bisect.bisect_left(pfs, x)
		ans.append(idx)
	for x in ans:
		if x <= n:
			print(x)
		else:
			print(-1)
while t:
	solve()
	t -= 1


import bisect, sys
from itertools import accumulate
input = sys.stdin.readline
for g in range(int(input())):
	(n, q) = list(map(int, input().split()))
	s = sorted(list(map(int, input().split())), reverse=True)
	p = [0] * len(s)
	p = list(accumulate(s))
	for _ in range(q):
		test = int(input())
		if p[-1] < test:
			print(-1)
		else:
			k = bisect.bisect_left(p, test)
			print(k + 1)


import bisect
from itertools import accumulate

def solve() -> str:
	(n, q) = map(int, input().split())
	candies = list(map(int, input().split()))
	candies.sort(reverse=True)
	sums = [0]
	sums.extend(accumulate(candies))
	results = []
	for _ in range(q):
		target = int(input())
		if target > sums[-1]:
			results.append('-1')
			continue
		results.append(str(bisect.bisect_left(sums, target)))
	return '\n'.join(results)
results = []
for _ in range(int(input())):
	results.append(solve())
print('\n'.join(results))


from bisect import bisect_left
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	for i in range(1, n):
		arr[i] = arr[i] + arr[i - 1]
	for _ in range(m):
		q = int(input())
		left = bisect_left(arr, q) + 1
		if left > n:
			print(-1)
		else:
			print(left)


import sys
import bisect

def solve():
	inp = sys.stdin.readline
	(n, q) = map(int, inp().split())
	a = list(map(int, inp().split()))
	a.sort(reverse=True)
	p = [0] * (n + 1)
	for i in range(n):
		p[i + 1] = p[i] + a[i]
	for i in range(q):
		x = int(inp())
		ans = bisect.bisect_left(p, x)
		if ans > n:
			print(-1)
		else:
			print(ans)

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


import sys
input = sys.stdin.readline
import bisect
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	d = [0] * n
	s = 0
	for i in range(n):
		s += a[i]
		d[i] = s
	for i in range(q):
		s = int(input())
		if s > d[-1]:
			print(-1)
		else:
			print(bisect.bisect_left(d, s) + 1)


import itertools as a
import bisect as b
(x, y) = (int, input)
for i in range(x(y())):
	((n, q), p) = (map(x, y().split()), list(a.accumulate(sorted(map(x, y().split()))[::-1])))
	print('\n'.join([str((b.bisect_left(p, x(y())) - n or -n - 2) + n + 1) for j in range(q)]))


import sys
import bisect
T = int(input())
for _ in range(T):
	(N, Q) = map(int, sys.stdin.readline().split())
	A = list(map(int, sys.stdin.readline().split()))
	A.sort()
	B = [0] * N
	B[-1] = A[-1]
	for i in range(N - 2, -1, -1):
		B[i] = B[i + 1] + A[i]
	B.reverse()
	for _ in range(Q):
		x = int(sys.stdin.readline())
		i = bisect.bisect_left(B, x)
		ans = i + 1
		print(ans if ans <= N else -1)


from sys import stdin
from bisect import bisect_left
t = int(stdin.readline())
while t > 0:
	t -= 1
	(n, q) = map(int, stdin.readline().split())
	a = sorted(map(int, stdin.readline().split()), reverse=True)
	b = [0] * n
	b[0] = a[0]
	for j in range(1, n):
		b[j] = b[j - 1] + a[j]
	for i in range(q):
		x = int(stdin.readline())
		y = bisect_left(b, x)
		if y > n - 1:
			print(-1)
		else:
			print(y + 1)


import sys
input = lambda : sys.stdin.readline().rstrip()
from bisect import bisect_left
INF = float('INF')

def solve():
	(N, Q) = map(int, input().split())
	A = list(map(int, input().split()))
	A = sorted(A, reverse=True)
	V = [INF] * (N + 1)
	V[0] = 0
	for j in range(N):
		V[j + 1] = V[j] + A[j]
	V[0] = -1
	for _ in range(Q):
		q = int(input())
		res = bisect_left(V, q)
		if res == N + 1:
			print(-1)
		else:
			print(res)
	return
T = int(input())
for _ in range(T):
	solve()


import sys
from bisect import bisect_left
from itertools import accumulate
readline = sys.stdin.readline
for _ in range(int(readline())):
	(n, q) = map(int, readline().split())
	ns = list(accumulate(sorted(map(int, readline().split()), reverse=True)))
	for _ in range(q):
		x = int(readline())
		index = bisect_left(ns, x, lo=0, hi=n)
		if index == n:
			print(-1)
		else:
			print(index + 1)


from collections import Counter
from functools import lru_cache
from bisect import bisect, bisect_left
t = int(input())
result = []
for _ in range(t):
	(n, q) = map(int, input().split())
	array = list(map(int, input().split()))
	queries = []
	for i in range(q):
		queries.append(int(input()))
	prefixSum = []
	array.sort(reverse=True)
	currentSum = 0
	for num in array:
		currentSum += num
		prefixSum.append(currentSum)
	ans = []
	for query in queries:
		currentIdx = bisect_left(prefixSum, query)
		if currentIdx >= len(prefixSum):
			ans.append(-1)
		else:
			ans.append(currentIdx + 1)
	for an in ans:
		print(an)


from bisect import *
from itertools import *
I = lambda : map(int, input().split())
for _ in range(*I()):
	(n, q) = I()
	x = [*accumulate(reversed(sorted(I())))]
	print(*(-1 if (a := bisect_left(x, *I())) == len(x) else a + 1 for _ in range(q)), sep='\n')


from bisect import bisect_left

def solve(lst, queries):
	lst.sort(key=lambda x: -x)
	lst = pref_sum(lst)
	for q in queries:
		id = bisect_left(lst, q) + 1
		if id > len(lst):
			print(-1)
		else:
			print(id)

def pref_sum(lst):
	s = 0
	ans = []
	for i in lst:
		s += i
		ans.append(s)
	return ans

def main():
	t = int(input())
	for i in range(t):
		(n, q) = list(map(int, input().split()))
		lst = list(map(int, input().split()))
		qs = []
		for i in range(q):
			qs.append(int(input()))
		solve(lst, qs)
main()


from bisect import bisect_left

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def exe():
	a = []
	count = []
	c = 0
	for i in lst:
		c += i
		count.append(c)
	maxi = max(count)
	for i in l:
		if i > maxi:
			print(-1)
			continue
		min_val = bisect_left(count, i)
		print(min_val + 1)
for i in range(int(input())):
	(n, q) = ma()
	lst = lis()
	lst.sort(reverse=True)
	l = [int(input()) for i in range(q)]
	exe()


from bisect import bisect_left
t = int(input())
while t > 0:
	(n, q) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	total = sum(a)
	queries = []
	for _ in range(q):
		queries.append(int(input()))
	a.sort(reverse=True)
	p = a[:]
	for i in range(1, n):
		p[i] = p[i - 1] + a[i]
	for x in queries:
		ans = bisect_left(p, x, 0, n)
		if ans <= n - 1:
			print(ans + 1)
		else:
			print(-1)
	t -= 1


from array import array
import collections
import sys
from collections import Counter, deque
import heapq
import bisect
import copy
MOD = 1000000007
NO = lambda : print('NO')
YES = lambda : print('YES')
_1 = lambda : print(-1)
ari = lambda : [int(_) for _ in input().split()]
cin = lambda : int(input())
cis = lambda : input()
show = lambda x: print(x)
fast = lambda : sys.stdin.readline()
test_case = 1
test_case = int(input())
sys.setrecursionlimit(10 ** 6)
dito = {}
idx = 0
for i in 'abcdefghijklmnopqrstuvwxyz':
	idx += 1
	dito[i] = idx

def ans():
	(n, q) = ari()
	arr = ari()
	query = []
	for i in range(q):
		query.append(cin())
	arr.sort(reverse=True)
	for i in range(1, n):
		arr[i] += arr[i - 1]
	for i in query:
		if arr[-1] < i:
			print(-1)
		else:
			idx = bisect.bisect_left(arr, i)
			print(idx + 1)
	return
for _ in range(test_case):
	ans()


import bisect

def method(arr, limit):
	if arr[-1] < limit:
		return -1
	index = bisect.bisect_left(preList, limit)
	return index + 1
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	pre = 0
	n = len(arr)
	preList = [0 for i in range(n)]
	for i in range(n):
		pre += arr[i]
		preList[i] = pre
	qs = []
	for _ in range(q):
		qs.append(int(input()))
	for q in qs:
		print(method(preList, q))


import bisect
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = [int(i) for i in input().split()]
	queries = []
	for i in range(q):
		queries.append(int(input()))
	a = sorted(a, reverse=True)
	b = a[:]
	for i in range(1, len(b)):
		b[i] = b[i - 1] + b[i]
	for i in range(q):
		ans = bisect.bisect_left(b, queries[i]) + 1
		if ans == len(b) + 1:
			print(-1)
		else:
			print(ans)


def task(n, a, q, qs):
	a.sort(reverse=True)
	sorted_qs = sorted(qs)
	sugar = 0
	j = 0
	results = dict()
	for i in range(q):
		if sugar >= sorted_qs[i]:
			results[sorted_qs[i]] = j
		else:
			while sugar < sorted_qs[i]:
				if j == n:
					results[sorted_qs[i]] = -1
					break
				sugar += a[j]
				j += 1
				if sugar >= sorted_qs[i]:
					results[sorted_qs[i]] = j
	for i in range(q):
		print(results[qs[i]])
t = int(input())
for i in range(0, t):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	qs = []
	for i in range(q):
		qs.append(int(input()))
	task(n, a, q, qs)


from bisect import *
from itertools import *
i = lambda : map(int, input().split())
for d in range(*i()):
	(n, q) = i()
	x = [*accumulate(reversed(sorted(i())))]
	print(*(-1 if (a := bisect_left(x, *i())) == len(x) else a + 1 for f in range(q)), sep='\n')


for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	dict = {}
	k = []
	for i in range(q):
		p = int(input())
		dict[p] = 0
		k.append(p)
	lst = list(dict.keys())
	count = 0
	j = 0
	lst.sort()
	a.sort(reverse=True)
	p = len(lst)
	for i in range(n):
		count += a[i]
		while j < p:
			if lst[j] <= count:
				dict[lst[j]] = i + 1
				j += 1
			else:
				break
	for i in k:
		if dict[i] == 0:
			print(-1)
		else:
			print(dict[i])


from collections import defaultdict as dfd

def solve(quan, quer):
	quan.sort(reverse=True)
	S = sum(quan)
	book = dfd(list)
	for (i, q) in enumerate(quer):
		book[q].append(i)
	arr_q = sorted(list(book.keys()))
	ans = [-1] * len(quer)
	(cnt, agg) = (0, 0)
	for q in arr_q:
		if q > S:
			break
		while agg < q:
			agg += quan[cnt]
			cnt += 1
		for idx in book[q]:
			ans[idx] = cnt
	return ans
T = int(input())
for _ in range(T):
	(N, Q) = list(map(int, input().split()))
	quan = list(map(int, input().split()))
	quer = []
	for _ in range(Q):
		quer.append(int(input()))
	ans = solve(quan, quer)
	for a in ans:
		print(a)


from bisect import bisect_left, bisect_right

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i < len(a) and a[i] >= x:
		return i + 1
	else:
		return -1
for t in range(int(input())):
	(n, q) = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	queries = []
	for i in range(q):
		queries.append(int(input()))
	d.sort(reverse=True)
	for i in range(1, n):
		d[i] += d[i - 1]
	t = True
	for i in range(q):
		res = BinarySearch(d, queries[i])
		print(res)


import sys
for _ in range(int(sys.stdin.readline())):
	(n, q) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	a.sort()
	f = [0] * q
	a.reverse()
	all_x = []
	for i in range(q):
		x = int(sys.stdin.readline())
		all_x.append((x, i))
	all_x.sort()
	ukaz1 = 1
	weight = a[0]
	for i in all_x:
		while ukaz1 <= n and weight < i[0]:
			ukaz1 += 1
			if ukaz1 < n + 1:
				weight += a[ukaz1 - 1]
		if ukaz1 == n + 1:
			f[i[1]] = -1
		else:
			f[i[1]] = ukaz1
	print(*f, sep='\n')


t = int(input())
for _ in range(t):
	(n, q) = list(map(int, input().split()))
	a = sorted(map(int, input().split()), reverse=True)
	s = []
	for i in range(q):
		s += [[int(input()), i]]
	sm = 0
	s = sorted(s)
	k = 0
	ans = [-1 for _ in range(q)]
	for i in range(n):
		sm += a[i]
		while k < q and sm >= s[k][0]:
			ans[s[k][1]] = i + 1
			k += 1
	print('\n'.join(map(str, ans)))


for _ in range(int(input())):
	requests = []
	(mysor, num_of_requests) = map(int, input().split())
	sugar = sorted(list(map(int, input().split())), reverse=True)
	answers = [-1] * num_of_requests
	summ = 0
	for i in range(num_of_requests):
		requests.append((int(input()), i))
	requests.sort()
	cur_request = 0
	for j in range(mysor):
		summ += sugar[j]
		while cur_request < num_of_requests and requests[cur_request][0] <= summ:
			answers[requests[cur_request][1]] = j + 1
			cur_request += 1
	print(*answers, sep='\n')


from pickle import FALSE
t = int(input())
for e in range(t):
	(n, q) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	que = []
	for i in range(q):
		que.append([int(input()), i])
	arr.sort(reverse=True)
	que.sort(key=lambda x: x[0])
	d = 0
	ans = 0
	ti = 0
	ee = {}
	for i in range(q):
		done = False
		if d >= que[i][0]:
			ee[que[i][1]] = ans
			continue
		while True:
			if ti >= n:
				break
			d += arr[ti]
			ti += 1
			ans += 1
			if d >= que[i][0]:
				done = True
				break
		if not done:
			ee[que[i][1]] = -1
		else:
			ee[que[i][1]] = ans
	for i in range(q):
		print(ee[i])


t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	candies = list(map(int, input().split()))
	candies.sort(reverse=True)
	total = sum(candies)
	sugar = []
	current = 0
	for candy in candies:
		current += candy
		sugar.append(current)
	queries = []
	for i in range(q):
		target = int(input())
		queries.append((i, target))
	queries.sort(key=lambda x: x[1])
	output = []
	i = 0
	for (ind, target) in queries:
		if target > sugar[-1]:
			output.append((ind, -1))
		else:
			while sugar[i] < target:
				i += 1
			if i == n - 1 and sugar[i] < target:
				output.append((ind, -1))
			else:
				output.append((ind, i + 1))
	output.sort(key=lambda x: x[0])
	for item in output:
		print(item[1])


from bisect import bisect_left
T = []
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	for i in range(1, n):
		a[i] += a[i - 1]
	for j in range(q):
		x = int(input())
		if x > a[-1]:
			T.append(-1)
		else:
			T.append(bisect_left(a, x) + 1)
for i in T:
	print(i)


from bisect import bisect_left
from itertools import accumulate
for i in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	l = list(accumulate(l))
	for j in range(q):
		x = int(input())
		ans = bisect_left(l, x) + 1
		if ans > n:
			ans = -1
		print(ans)


t = int(input())

def bs(ps, x):
	(l, r) = (0, len(ps) - 1)
	while l < r:
		mid = (r + l) // 2
		if ps[mid] < x:
			l = mid + 1
		else:
			r = mid
	return l if ps[l] >= x else -1
for _ in range(t):
	(n, q) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	ps = []
	for i in a:
		ps.append(i + (ps[-1] if ps else 0))
	x = [int(input()) for _ in range(q)]
	for i in x:
		val = bs(ps, i)
		print(val + (1 if val != -1 else 0))


from collections import Counter, deque
from collections import OrderedDict
import math
from random import randint
from bisect import bisect, bisect_left
import sys
import re
MOD = 10 ** 9 + 7
MAX = -sys.maxsize
MIN = sys.maxsize

class get:

	def int():
		return list(map(int, input().split()))

	def str():
		return input().split()

	def float():
		return list(map(float, input().split()))

	def map():
		return map(int, input().split())

def sqrt(x):
	return int(math.sqrt(x)) + 1

def gcd(*args):
	result = args[0]
	for item in args:
		result = math.gcd(result, item)
	return result

def LCM(a, b):
	return a * b // math.gcd(a, b)

def isPrime(n):
	if n == 1:
		return False
	for i in range(2, sqrt(n)):
		if n % i == 0:
			return False
	return True

def solve():
	(n, q) = get.map()
	a = get.int()
	a.sort(reverse=True)
	c = 0
	sum_ = sum(a)
	for i in range(n):
		c += a[i]
		a[i] = c
	for _ in range(q):
		x = int(input())
		if x > sum_:
			print(-1)
			continue
		kk = bisect_left(a, x)
		print(kk + 1)
t = int(input())
for tt in range(t):
	solve()


import sys
import threading
from math import inf
from bisect import bisect_left
from collections import defaultdict, deque

def li():
	return list(map(int, input().split()))

def nn():
	return int(input().split())

def w():
	return input()

def solve():
	(n, q) = li()
	arr = li()
	arr.sort(reverse=True)
	tot = sum(arr)
	for i in range(1, n):
		arr[i] += arr[i - 1]
	for i in range(q):
		qr = int(input())
		if qr > tot:
			idx = -1
		else:
			idx = bisect_left(arr, qr)
		print(idx + 1) if idx != -1 else print(idx)

def main():
	t = int(input())
	for i in range(t):
		solve()
main()


from itertools import accumulate
from bisect import bisect_left

def solve():
	(n, q) = map(int, input().split())
	arr = list(accumulate(sorted(list(map(int, input().split())), reverse=True)))
	for i in range(q):
		a = int(input())
		x = bisect_left(arr, a)
		if x < n:
			print(x + 1)
		else:
			print(-1)
t = int(input())
for _ in range(t):
	solve()


import bisect
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	a.sort(reverse=True)
	for i in range(1, n):
		a[i] += a[i - 1]
	for i in range(q):
		x = int(input())
		mark = bisect.bisect_left(a, x)
		if mark == n:
			print(-1)
		else:
			print(mark + 1)


from bisect import bisect_left
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	pre = [0]
	for num in a:
		pre.append(pre[-1] + num)
	mx = pre[-1]
	for _ in range(q):
		x = int(input())
		if x > mx:
			print(-1)
		else:
			ans = bisect_left(pre, x)
			print(ans)


from bisect import bisect_left
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	arr.reverse()
	for i in range(n - 1):
		arr[i + 1] += arr[i]
	for i in range(q):
		i = bisect_left(arr, int(input()))
		if i >= n:
			print(-1)
		else:
			print(i + 1)


import bisect

def main():
	(n, q) = map(int, input().split())
	sweets = [int(x) for x in input().split()]
	sweets.sort(reverse=True)
	prefix_sum = [sweets[0]] * n
	for i in range(1, n):
		prefix_sum[i] = prefix_sum[i - 1] + sweets[i]
	for _ in range(q):
		x = int(input())
		result = bisect.bisect_left(prefix_sum, x)
		if result == n:
			print(-1)
		else:
			print(result + 1)
t = int(input())
for _ in range(t):
	main()


import bisect

def solve(n, q, A):
	A.sort(reverse=True)
	A_accum = [A[0]]
	for a in A[1:]:
		A_accum.append(a + A_accum[-1])
	for _ in range(q):
		x = int(input())
		i = bisect.bisect_left(A_accum, x)
		if i >= n:
			print(-1)
		else:
			print(i + 1)
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	A = list(map(int, input().split()))
	solve(n, q, A)


import bisect
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	a = list(map(int, input().strip().split()))
	a.sort(reverse=True)
	p = [a[0]]
	for i in range(1, n):
		p.append(p[-1] + a[i])
	for j in range(q):
		x = int(input())
		idx = bisect.bisect_left(p, x)
		if idx <= n - 1:
			print(idx + 1)
		else:
			print(-1)


from bisect import bisect_left
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a = a[::-1]
	adds = [a[0]]
	for i in range(1, n):
		adds.append(adds[-1] + a[i])
	for i in range(q):
		x = int(input())
		ans = bisect_left(adds, x)
		if ans == n:
			print(-1)
		else:
			print(ans + 1)


from itertools import accumulate
from bisect import bisect, bisect_left
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	a = list(accumulate(a))
	for _ in range(q):
		x = int(input())
		if a[-1] < x:
			print(-1)
		else:
			print(bisect_left(a, x) + 1)


from bisect import *
from itertools import *
for s in range(int(input())):
	(n, q) = map(int, input().split())
	c = list(map(int, input().split()))
	c.sort()
	c.reverse()
	c = list(accumulate(c))
	for i in range(q):
		num = int(input())
		xb = bisect_left(c, num)
		print('-1' if xb == n else xb + 1)


from itertools import accumulate
import bisect
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	prefix = list(accumulate(a))
	for i in range(q):
		res = bisect.bisect_left(prefix, int(input()))
		print(res + 1 if res != n else -1)


def solve(n, q, arr, query):
	su = sum(arr)
	arr.sort()
	arr.reverse()
	for i in range(1, n):
		arr[i] += arr[i - 1]
	res = []
	for x in query:
		l = 0
		h = n - 1
		temp = 0
		if x > su:
			res.append(-1)
			continue
		while l <= h:
			mid = (l + h) // 2
			if arr[mid] == x:
				res.append(mid + 1)
				temp = 1
				break
			elif arr[mid] > x:
				h = mid - 1
			else:
				l = mid + 1
		if temp == 0:
			res.append(l + 1)
	return res
t = int(input())
for _ in range(t):
	(n, q) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	query = []
	for _ in range(q):
		x = int(input())
		query.append(x)
	res = solve(n, q, arr, query)
	for x in res:
		print(x)
	print()


import bisect
for t in range(int(input())):
	(n, q) = map(int, input().split())
	items = sorted(list(map(int, input().split())), reverse=True)
	add = [0] * (n + 1)
	for i in range(1, n + 1):
		add[i] = add[i - 1] + items[i - 1]
	for i in range(q):
		x = int(input())
		if x > add[n]:
			print(-1)
		else:
			print(bisect.bisect_left(add, x))


from itertools import accumulate
from bisect import bisect_left
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	candy = list(accumulate(sorted(list(map(int, input().split())), reverse=True)))
	for i in range(q):
		req = int(input())
		t = bisect_left(candy, req)
		print(t + 1 if n > t else -1)


from itertools import accumulate
from bisect import bisect_left

def solve():
	(n, q) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	p = list(accumulate(a))
	for _ in range(q):
		x = int(input())
		i = bisect_left(p, x) + 1
		print(i if i <= n else -1)
for _ in range(int(input())):
	solve()


import bisect
R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, q) = R()
	L = list(R())
	L = sorted(L, reverse=True)
	for i in range(1, n):
		L[i] += L[i - 1]
	for i in range(q):
		p = int(input())
		res = bisect.bisect_left(L, p)
		if res == n:
			print(-1)
		else:
			print(res + 1)


import bisect
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a = sorted(a, reverse=True)
	for i in range(1, n):
		a[i] += a[i - 1]
	for i in range(q):
		x_i = int(input())
		j = bisect.bisect_left(a, x_i)
		if j == n:
			print(-1)
		else:
			print(j + 1)


import bisect
for j in range(0, int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	ls = [l[0]]
	for x in range(1, n):
		ls.append(l[x] + ls[x - 1])
	for z in range(0, k):
		n1 = int(input())
		a = bisect.bisect_left(ls, n1)
		if a == n:
			print(-1)
		else:
			print(a + 1)


from bisect import bisect_left
for i in range(int(input())):
	(n, q) = map(int, input().split())
	l = [int(x) for x in input().split()]
	l.sort(reverse=True)
	s = 0
	for i in range(1, n):
		l[i] += l[i - 1]
	for k in range(q):
		a = int(input())
		ans = bisect_left(l, a) + 1
		print(ans if ans <= n else -1)


import sys
input = sys.stdin.readline

def bin(a, n):
	l = 0
	h = len(a) - 1
	while l <= h:
		m = (h + l) // 2
		if a[m] == n:
			return m
		if a[m] < n:
			l = m + 1
		else:
			h = m - 1
	return l
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	b = [0] * n
	b[0] = a[0]
	for i in range(1, n):
		b[i] = b[i - 1] + a[i]
	for i in range(m):
		q = int(input())
		if q > b[-1]:
			print(-1)
			continue
		ans = bin(b, q)
		print(ans + 1)


from bisect import bisect_left
for _ in range(int(input())):
	(n, q) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	a = sorted(a, reverse=True)
	for i in range(1, n):
		a[i] = a[i] + a[i - 1]
	for i in range(q):
		qi = int(input())
		left = bisect_left(a, qi) + 1
		if left > n:
			print(-1)
		else:
			print(left)


from bisect import bisect_left
for _ in range(int(input())):
	inp = input().split()
	(n, m) = (int(inp[0]), int(inp[1]))
	arr = list(map(int, input().split()))
	sumi = sum(arr)
	arr = sorted(arr, key=lambda x: -x)
	prefix = arr[:]
	for i in range(1, len(arr)):
		prefix[i] += prefix[i - 1]
	for i in range(m):
		val = int(input())
		if sumi < val:
			print(-1)
		elif sumi == val:
			print(n)
		else:
			print(bisect_left(prefix, val) + 1)


import bisect
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	for i in range(1, n):
		l[i] += l[i - 1]
	for i in range(q):
		a = int(input())
		index = bisect.bisect_left(l, a)
		index += 1
		if index > n:
			index = -1
		print(index)


from itertools import accumulate

def binary_search(arr, x):
	res = -1
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] >= x:
			high = mid - 1
			res = mid
	return res if res == -1 else res + 1
cases = int(input())
for _ in range(cases):
	(candies_count, queries_count) = map(int, input().split(' '))
	sugar_content = sorted(list(map(int, input().split(' '))), reverse=True)
	prefix_sums = list(accumulate(sugar_content))
	queries = []
	for _ in range(queries_count):
		queries.append(int(input()))
	for target in queries:
		print(binary_search(prefix_sums, target))


from bisect import bisect_left as bl
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	can = sorted(list(map(int, input().split())), reverse=1)
	adds = [can[0]]
	for i in range(1, n):
		adds.append(adds[i - 1] + can[i])
	for i in range(q):
		chahiye = int(input())
		ans = bl(adds, chahiye)
		if ans == n:
			print(-1)
		else:
			print(ans + 1)


from bisect import bisect_left
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	x = list(map(int, input().split()))
	x.sort(reverse=True)
	for i in range(n - 1):
		x[i + 1] += x[i]
	ans = x[-1]
	for _ in range(q):
		s = int(input())
		if s > ans:
			print(-1)
		elif s == ans:
			print(len(x))
		else:
			l = bisect_left(x, s)
			print(l + 1)


from itertools import accumulate
from bisect import bisect_left
for t in range(int(input())):
	(n, q) = map(int, input().split())
	l = sorted(map(int, input().split()), reverse=True)
	val = [*accumulate(l)]
	for i in range(q):
		x = int(input())
		print([bisect_left(val, x) + 1, -1][x > val[-1]])


from bisect import bisect_left
tests = int(input())
for test in range(tests):
	(candy, query) = tuple(map(int, input().split(' ')))
	sg = list(map(int, input().split(' ')))
	sg.sort(key=lambda x: -x)
	for i in range(1, candy):
		sg[i] += sg[i - 1]
	for q in range(query):
		target = int(input())
		ind = bisect_left(sg, target)
		if ind >= candy:
			print(-1)
		else:
			print(ind + 1)


from bisect import bisect_left
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	arr = sorted(list(map(int, input().split())), reverse=True)
	prev = 0
	l = []
	for e in arr:
		l.append(e + prev)
		prev += e
	for _ in range(q):
		x = int(input())
		if l[-1] < x:
			print(-1)
		else:
			print(bisect_left(l, x) + 1)


from sys import stdin, stdout
import collections
import math

def solve(l, q):
	n = len(l)
	if q > l[-1]:
		return -1
	(s, e) = (0, n - 1)
	while s <= e:
		m = (s + e) // 2
		if q < l[m]:
			e = m - 1
		elif q > l[m]:
			s = m + 1
		else:
			return m
	return s

def main():
	for _ in range(int(input())):
		(n, q) = map(int, input().split())
		l = list(map(int, input().split()))
		l.sort(reverse=True)
		for i in range(1, n):
			l[i] += l[i - 1]
		for i in range(q):
			x = int(input())
			ans = solve(l, x)
			if ans == -1:
				ans = -2
			print(ans + 1)
	return
input = stdin.readline
main()


from bisect import bisect_left
while True:
	try:
		test = int(input())
	except EOFError:
		break
	for i in range(test):
		(n, q) = map(int, input().split(' '))
		arr = sorted(map(int, input().split(' ')), reverse=True)
		for i in range(1, len(arr)):
			arr[i] += arr[i - 1]
		for i in range(q):
			a = int(input())
			ans = bisect_left(arr, a) + 1
			if ans > n:
				print(-1)
			else:
				print(ans)


import bisect
x = int(input())
for jj in range(x):
	(n, m) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	a.sort(reverse=True)
	t = [0] * n
	for i in range(n):
		t[i] = t[i - 1] + a[i]
	for i in range(m):
		q = int(input())
		if q > t[-1]:
			print(-1)
		else:
			print(bisect.bisect_left(t, q) + 1)


from itertools import accumulate
from bisect import bisect_left
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	can = list(map(int, input().split()))
	can.sort(reverse=True)
	p = list(accumulate(can))
	for _ in range(q):
		idx = bisect_left(p, int(input()))
		if idx == n:
			print(-1)
		else:
			print(idx + 1)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def find(sums, query):
	left = 0
	right = len(sums) - 1
	answer = -1
	while left <= right:
		middle = left + (right - left) // 2
		if sums[middle] >= query:
			answer = middle + 1
			right = middle - 1
		else:
			left = middle + 1
	return answer
t = inp()
answer = []
for i in range(t):
	(n, m) = inlt()
	candies = inlt()
	candies.sort(reverse=True)
	sums = []
	su_m = 0
	for i in range(n):
		su_m += candies[i]
		sums.append(su_m)
	for i in range(m):
		query = inp()
		answer.append(find(sums, query))
for ans in answer:
	print(ans)


from bisect import bisect
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	sumA = [0] * (n + 1)
	for i in range(n):
		sumA[i + 1] = a[i] + sumA[i]
	while q != 0:
		x = int(input())
		num = bisect(sumA, x - 1)
		print(num if num <= n else -1)
		q = q - 1


from bisect import bisect_left
x = int(input())
for _ in range(x):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	(s, suffix_sum) = (0, [])
	for a_i in a[::-1]:
		s += a_i
		suffix_sum.append(s)
	for j in range(q):
		x_j = int(input())
		res = bisect_left(suffix_sum, x_j) + 1
		if res > n:
			res = -1
		print(res)


from itertools import accumulate
import bisect
I = input
for _ in range(int(I())):
	(n, q) = map(int, I().split())
	lst = list(map(int, I().split()))
	presum = list(accumulate(sorted(lst, reverse=True)))
	for _ in range(q):
		i = int(I().strip())
		idx = bisect.bisect_left(presum, i)
		print(-1 if idx == len(presum) else idx + 1)


from bisect import bisect_left
for t in range(int(input())):
	(n, q) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	sm = 0
	num_list = []
	for i in a:
		num_list.append(sm + i)
		sm += i
	for i in range(q):
		x = int(input())
		if num_list[-1] >= x:
			print(bisect_left(num_list, x) + 1)
		else:
			print(-1)


import bisect
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	ax = []
	curr = 0
	for i in range(len(a) - 1, -1, -1):
		curr += a[i]
		ax.append(curr)
	for i in range(m):
		q = int(input())
		if q > ax[-1]:
			print(-1)
		else:
			x = bisect.bisect_right(ax, q)
			if ax[x - 1] == q:
				print(x)
			else:
				print(x + 1)


from bisect import bisect_left
for _ in range(int(input())):
	(n, q) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	l = sorted(l)[::-1]
	temp = []
	sum = 0
	for x in l:
		sum += x
		temp.append(sum)
	for i in range(q):
		t = int(input())
		if t < temp[0]:
			print(1)
			continue
		if t > temp[-1]:
			print(-1)
			continue
		mid = bisect_left(temp, t)
		print(mid + 1)


from bisect import bisect_right
_ = int(input())
for __ in range(_):
	(n, q) = map(int, input().split())
	candies = sorted(list(map(int, input().split())))
	candies_sum = [candies[0]]
	for z in range(1, n):
		candies_sum.append(candies[z] + candies_sum[-1])
	for x in range(q):
		query = int(input())
		if query > candies_sum[-1]:
			print(-1)
			continue
		search_for = candies_sum[-1] - query
		pos = bisect_right(candies_sum, search_for)
		print(n - pos)


import bisect
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	cans = list(map(int, input().split()))
	cans.sort(reverse=True)
	s = cans[0]
	pcans = [s]
	for i in range(1, len(cans)):
		s += cans[i]
		pcans.append(s)
	for i in range(q):
		query = int(input())
		ansx = bisect.bisect_left(pcans, query)
		if ansx + 1 > n:
			print(-1)
		else:
			print(ansx + 1)


import bisect
for pratyush in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	p = [l[0]]
	for x in range(1, n):
		p.append(l[x] + p[x - 1])
	for i in range(0, k):
		m = int(input())
		a = bisect.bisect_left(p, m)
		if a == n:
			print(-1)
		else:
			print(a + 1)


import bisect
t = int(input())
for _ in range(t):
	(n, q) = map(int, input().split())
	sug = sorted([int(x) for x in input().split()])[::-1]
	pr = [0] * (n + 1)
	for i in range(1, n + 1):
		pr[i] = pr[i - 1] + sug[i - 1]
	for _ in range(q):
		x = int(input())
		res = bisect.bisect_left(pr, x)
		if res > n:
			print('-1')
		else:
			print(res)


from bisect import bisect_left
for i in range(int(input())):
	(n, q) = map(int, input().split())
	sweets = sorted(list(map(int, input().split())), reverse=True)
	data = []
	summ = 0
	for i in sweets:
		summ += i
		data.append(summ)
	for i in range(q):
		x = int(input())
		answer = bisect_left(data, x)
		if answer == len(data):
			print(-1)
		else:
			print(answer + 1)


from bisect import bisect, bisect_left, bisect_right

def busquedaBinaria(lista, abuscar):
	inicio = 0
	final = len(lista) - 1
	res = -1
	while inicio <= final and res == -1:
		m = (inicio + final) // 2
		if lista[m] == abuscar:
			res = m
		elif abuscar < lista[m]:
			final = m - 1
		else:
			inicio = m + 1
	return res
t = int(input())
for _ in range(t):
	(n, q) = list(map(int, input().split()))
	lista = list(map(int, input().split()))
	lista.sort(reverse=True)
	res = [lista[0]]
	for i in range(1, len(lista)):
		res.append(lista[i] + res[-1])
	for i in range(q):
		c = int(input())
		if c > res[-1]:
			print(-1)
		else:
			found = bisect_left(res, c)
			print(found + 1)


from bisect import bisect_left
import sys
for _ in range(int(input())):
	(n, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)[::-1]
	l = sum(a)
	prefix = []
	for (i, item) in enumerate(a):
		k = item
		if i:
			k += prefix[-1]
		prefix.append(k)
	for _ in range(q):
		o = int(input())
		if o > l:
			print(-1)
			continue
		index = bisect_left(prefix, o)
		print(index + 1)