The binomial coefficient C(N, K) is defined as
N! / K! / (N − K)! for 0 ≤ K ≤ N.
Here N! = 1 * 2 * ... * N for N ≥ 1, and 0! = 1.
You are given a prime number P and a positive integer N.
AL is defined as the number of elements in the sequence C(N, K), such that, PL divides C(N, K), but PL+1 does not divide C(N, K). Here, 0 ≤ K ≤ N.
Let M be an integer, such that, AM > 0, but AL = 0 for all L > M. Your task is to find numbers A0, A1, ..., AM.
Input Format
The first line of the input contains an integer T, denoting the number of test cases.
The description of T test cases follows.
The only line of each test case contains two space-separated integers N and P.
Output Format
For each test case, display M + 1 space separated integers
A0, A1, ..., AM
on the separate line.
Constraints
1 ≤ T ≤ 100
1 ≤ N ≤ 1018
2 ≤ P < 1018
P is prime
Sample Input
3
4 5
6 3
10 2
Sample Output
5
3 4
4 4 1 2
Explanation
Example case 1. Values C(4, K) are {1, 4, 6, 4, 1}. Each of them is not divisible by 5. Therefore, A0 = 5, A1 = 0, A2 = 0, ..., hence the answer.
Example case 2. Values C(6, K) are {1, 6, 15, 20, 15, 6, 1}. Among them 1, 20, 1 are not divisible by 3, while remaining values 6, 15, 15, 6 are divisible by 3, but not divisible by 9. Therefore, A0 = 3, A1 = 4, A2 = 0, A3 = 0, ..., hence the answer.
Example case 3. Values C(10, K) are {1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1}. Among them 1, 45, 45, 1 are not divisible by 2, values 10, 210, 210, 10 are divisible by 2, but not divisible by 4, value 252 is divisible by 4, but not divisible by 8, finally, values 120, 120 are divisible by 8, but not divisible by 16. Therefore, A0 = 4, A1 = 4, A2 = 1, A3 = 2, A4 = 0, A5 = 0, ..., hence the answer.