#DIVFACT3. Divisors of factorial (hard)

Divisors of factorial (hard)

Factorial numbers are getting big very soon, you'll have to compute the number of divisors of such highly composite numbers.

Input

The first line contains an integer T, the number of test cases.
On the next T lines, you will be given two integers N and M.

Output

Output T lines, one for each test case, with the number of divisors of the factorial of N.
Since the answer can get very big, output it modulo M.

Example

Input:
3
2 1000
3 11
4 5
Output:
2
4
3

Constraints

0 < T < 5432
1 < N < 10^8
1 < M < 10^9

For N, M : uniform random input in the range.
One input file.

Information

As it is possible to solve DIVFACT2 with fast language and intermediate method, here is the hard edition.
Warning : It could be very hard or impossible to solve this problem with slow languages.
Time limit is approx ×4 my unoptimized C_time. Good luck and have fun ;-) (Edit 2017-02-11 ; TL updated ; compiler changes)