CERI2018L - Number of divisors of factorial

The goal of the problem is to compute the number of divisors of Factorial(n)\text{Factorial}(n).

Input

The first line of the input consist of a single integer number tt which determines the number of tests.

In each of next tt lines there is two integer numbers nn and mm.

Constraints

  • 0<t<1020 < t < 10^2 ;
  • 0<n<2×1050 < n < 2\times10^5 ;
  • 1<m<2×1091 < m < 2\times10^9.

Output

For each test case, print the number of divisors of n!(modm)n! \pmod m.

Example

Input:
3
2 1000
3 100
1234 1000000007

Output:
2
4
787315782

Explanation

For the first test case, 2!=1×2=22! = 1\times2=2, whose number of divisors is 22.

For the second test case, 3!=1×2×3=63! = 1\times2\times3=6, whose number of divisors is 44.


Added by:Francky
Date:2018-05-08
Time limit:10s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

hide comments
2018-05-08 14:38:25 wisfaq
whom should be whose
(whose is the genitive)
=(Francky)=> Corrected ; thanks again.

Last edit: 2018-05-08 14:55:34
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.