- Time limit: 1.00 s
- Memory limit: 512 MB
Given two integers and , your task is to count the number of arrays of positive integers where for all .
Input
The first line has an integer : the number of test cases.
The next lines have two integers and : the length of the array and the value of lcm.
Output
Print integers: the answer to each test case modulo .
Constraints
Example
Input:
3 3 4 4 6 1337 42
Output:
11 64 602746233
Explanation: The arrays for the first test case are , , , , , , , , , and .