CSES - Counting LCM Arrays
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Given two integers nn and kk, your task is to count the number of arrays a1,a2,,ana_1, a_2,\dots, a_n of positive integers where lcm(ai,ai+1)=k\operatorname{lcm}(a_i, a_{i+1}) = k for all 1i<n1 \le i < n.

Input

The first line has an integer tt: the number of test cases.

The next tt lines have two integers nn and kk: the length of the array and the value of lcm.

Output

Print tt integers: the answer to each test case modulo 109+710^9 + 7.

Constraints

  • 1t10001 \le t \le 1000
  • 2n1092 \le n \le 10^9
  • 1k1091 \le k \le 10^9

Example

Input:

3
3 4
4 6
1337 42

Output:

11
64
602746233

Explanation: The arrays for the first test case are [1,4,1][1, 4, 1], [1,4,2][1, 4, 2], [1,4,4][1, 4, 4], [2,4,1][2, 4, 1], [2,4,2][2, 4, 2], [2,4,4][2, 4, 4], [4,1,4][4, 1, 4], [4,2,4][4, 2, 4], [4,4,1][4, 4, 1], [4,4,2][4, 4, 2] and [4,4,4][4, 4, 4].