Smart Strategy

All submissions for this problem are available.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef found a very useful opensource code for the current problem. Unfortunately, one fragment of code isn't optimized. Consider that problem: given an array D of size N and Q queries X to the following opensource code:
read X
for i = 1..N:
X = floor(X / D[i])
print X
Help Chef to optimize that code for all possible X, he will be very thankful :)
Input

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains two integers  N and Q. The second line contains array D. The third line contains Q queries  X_{1}, X_{2}, ..., X_{Q}.
Output

For every test case in single line output Q integers  for each X_{i} output result for this query.
Constraints
 1 ≤ T ≤ 1000
 1 ≤ N, Q ≤ 10^{5}
 1 ≤ X_{i}, D_{i} ≤ 10^{9}
 Sum of N over all test cases ≤ 3*10^{5}
 Sum of Q over all test cases ≤ 3*10^{5}
Subtasks
 Subtask #1: (25 points) sum of N over all test cases ≤ 3*10^{3} and sum of Q over all test cases ≤ 3*10^{3}
 Subtask #2: (75 points) Original constraints
Example
Input: 2 2 3 2 3 5 100 8 3 2 2 2 2 16 8 Output: 0 16 1 2 1
Explanation
Example case 1. [[5 / 2] / 3] = 0, [[100 / 2] / 3] = 16, [[8 / 2] / 3] = 1
Author:  mgch 
Tester:  alex_2oo8 
Editorial  https://discuss.codechef.com/problems/SMRSTR 
Tags  cakewalk, ltime54, mgch 
Date Added:  20112017 
Time Limit:  0.5 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 