## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## Eating Queries Codeforces Solution | Codeforces Problem Solution 2022

E. Eating Queries
time limit per test
3.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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\le t\le 1000$)  — the number of test cases. The description of test cases follows.

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

Most Similar Words Codeforces Solution

The second line contains $n$ integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($1\le {a}_{i}\le {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\le {x}_{j}\le 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.