Under construction

Still being built. Things may change

Maximum Number of Divisors

Time limit1sMemory limit256 MB

Summary
You answer each query with the largest divisor count among integers from 1 to N that are not multiples of P.
Level

Easy3 of 10

Topics
Number theory, Prefix sum
Solved
No attempts yet

Problem

Mr. Strange dislikes the number PP, so you have to solve this problem for him.

Among the integers from 11 to NN, keep only the ones that are not divisible by PP. Report the largest number of divisors any of the kept integers has.

Since P≥2P \ge 2, the number 11 always survives, so the answer is at least 11.

Input

The first line contains the number of data sets TT (2≤T≤1002 \le T \le 100).

Each data set consists of three lines. The first line contains the number PP (2≤P≤109+72 \le P \le 10^9 + 7) that Mr. Strange dislikes. The second line contains the number of intervals KK (1≤K≤1001 \le K \le 100). The third line contains KK space separated integers N1,N2,…,NKN_1, N_2, \dots, N_K (1≤Ni≤42421 \le N_i \le 4242), where NiN_i is the right end of the interval [1,Ni][1, N_i].

Output

Print one line per data set. Each line holds the KK answers for that data set in the order given, separated by single spaces. The ii-th value is the largest number of divisors among the integers in [1,Ni][1, N_i] that are not divisible by PP.

Notes

With P=13P = 13 and the interval [1,8][1, 8], no multiple of 1313 is at most 88. The numbers with the most divisors are 66 (divisors 1,2,3,61, 2, 3, 6) and 88 (divisors 1,2,4,81, 2, 4, 8), so the answer is 44. Over [1,42][1, 42] the number 3636 has 99 divisors, which is the most.

With P=6P = 6 the numbers 6,12,18,24,30,36,426, 12, 18, 24, 30, 36, 42 are forbidden. Over [1,8][1, 8] the maximum 44 is now reached only by 88. Over [1,42][1, 42] no remaining number has 99 divisors, so the answer is 88, reached by 4040.

Examples2

  1. Example 1

    Input
    2
    13
    2
    8 42
    6
    2
    8 42
    
    Expected output
    4 9
    4 8
    
  2. Example 2

    Input
    3
    2
    2
    1 8
    3
    2
    1 42
    4243
    2
    1 4242
    
    Expected output
    1 2
    1 8
    1 48