#P61. [KBC005E] Count 2
[KBC005E] Count 2
Source
This problem is moved from Long Long OJ (Copyright by Codeforces). All rights reserved.
Adapted from: https://codeforces.com/contest/893/problem/E
Problem Description
There are multiple test cases. For each test case, given and , find the number of sequences of length whose product equals .
Negative numbers are allowed in the sequence. Calculate the number of such sequences, modulo .
Input Format
This problem contains multiple test cases.
The first line contains a positive integer representing the number of test cases to solve.
Each of the next lines contains two positive integers .
Output Format
For each test case, output a non-negative integer representing the answer.
Samples
2
6 3
4 2
36
6
Sample Explanation
The possible sequences are as follows:
- .
- .
- .
- .
- .
- .