


The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains two space-separated integers ‘n’ and ‘q’, where ‘n’ denotes the number of elements in the array ‘arr’ and ‘q’ denotes the number of elements in array ‘queries’.
The second line of each test case contains ‘n’ space-separated integers denoting the elements of the array ‘arr’.
The third line of each test case contains ‘q’ space-separated integers denoting the elements of the array ‘queries’.
For every test case, return the arraylist/list/vector of size ‘q’ denoting the answer to each query.
Output for each test case will be printed in a separate line.
1. You do not need to print anything; it has already been taken care of. Just implement the given function.
2. Given array ‘arr’ is sorted in ascending order.
1 <= T <= 100
1 <= N <= 1000
1 <= Q <= 1000
-10^9 <= arr[i] <= 10^9
-10^9 <= query[i] <= 10^9
Where ‘T’ represents the number of test cases, ‘N’ is the number of elements in array ‘arr’, ‘Q’ denotes the number of elements in array ‘queries’. ‘arr[i]’ represents the value of the number at ‘i’ position in ‘arr’. ‘query[i]’ represents the value of ‘i-th’ queries.
Time Limit : 1 sec
For each query, we can iterate over the array ‘arr’ and find the required sum.
The basic idea is to store the prefix sum for every index ‘i’. We will maintain a prefix sum array in which 'prefixSum[i]’ represents all elements from ‘0’ to ‘i-th’ index.
We have to find the index ‘idx’ of the last element in ‘arr’, which is less than or equal to ‘x’. We can find ‘idx’ using binary search over ‘arr’ as ‘arr’ is sorted. Then our answer will be ‘prefixSum[ idx-1]’.