For some number X, let F(X) denote the total number of sequences having length ≤ K such that bitwise OR of all the elements in a sequence is equal to X.
For a given N , K and prime p, calculate the value of ∑Ni=0 pi * F(i).
Input:
Input will consists of several test cases.
First line of input will consists of a single integer T denoting the number of test cases.
Each of the next T lines consist of integers N , K and p separated by a single space.
Output:
For each test case, output ∑Ni=0 pi * F(i). Since, the value can be large, output the value modulo 109+7.
Constraints:
For first test case, F(0) = 2, F(1) = 4, F(2)=4, F(3) = 10.
For second test case, F(0) = 3, F(1)= 11, F(2)= 11, F(3)= 59, F(4)= 11, F(5)= 59.