Find Greater

3

2 votes
Problem

Eva loves numbers. She has a list A of n distinct numbers containing numbers A1,A2....,An. She wants to get more numbers, so she decided to create a new list B

As she wants to get more numbers, she decides to copy numbers from list A to list B in a weird way :

  • She picks numbers from list A one by one from A1 to An.   
  • She picks an element Ai (1 < i < n) from list A, copies that element in list B.
  • Then, she copies all the numbers from list A valued between Ai and 2*Ai (inclusive) to list B.

Now, she has a lot of numbers in list B and Zan is interested in her new list B.

He ask her some queries. In each query, he gives her a number x, Eva has to answer that how many elements are greater than x in her new list B.

As, she has already done a lot of work in creating list B. You have to answer queries for her.

Example:

If she has list A = {1,2,3,4} and B = { }.

For A1,A2,...,A4:

  • She picks A1 = 1.
  • She copies A1 to B. Now, B = {1}.
  • She picks all the numbers from list A valued between Ai and 2*Ai, and copies them to list B. Now, B = {1,1,2}.
  • Repeat for A2,...,A4.

 The final list B = {1,1,2,2,2,3,3,3,4,4,4,4}.

Input

The first line contains an integer t (1 ≤ t ≤ 102) — the number of test cases in the input. Then t test cases follow.

The first line contains two positive integers n,q (1 ≤ n ,q ≤ 104) — length of the list A and number of the queries respectively.

The second line contains n positive integers A1,A2,…,An ( 0 ≤ Ai ≤ 104 ), where Ai is the  i-th element of the list A .

Next q lines contains an integer x (0 < x < 104).

Output

You have to ouput answer for each query - the number of elements greater than x in the list B.

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In first testcase:

After copying the numbers from list A according to the mentioned way, the list B =  {1,1,2,2,2,3,3,3,4,4,4,4,5,5,5,5}.

Then answer the queries, according to the list B.

In first query, the number of elements which are greater than 1 are 14.

In second query, the number of elements which are greater than 2 are 11.

In third query, the number of elements which are greater than 3 are 8.

In fourth query, the number of elements which are greater than 4 are 4.

In fifth query, the number of elements which are greater than 5 are 0.

 

Editor Image

?