Tubby the doggu wants you to solve a problem for him/her.
You have to find number of numbers between L to R inclusive whose binary representation of length P contains equal number of 0′s and 1′s. It is guaranteed that P≥ceil(log2(R+1)) . Here ceil(x) denotes the largest integer greater than or equal to x.
Example : Binary representation of number 5 of length 5 is 00101.
Input Format
The first line will consist of the integer T denoting the number of test cases.
For each of the T test cases, there will be single line containing 3 integers L,R and P.
Output Format
For each of the T test cases, output a single integer denoting the number of numbers between L to R inclusive whose binary representation of length P contains equal number of 0′s and 1′s.
Constraints
1≤T≤300000
1≤L≤R≤1016
1≤P≤60
P≥ceil(log2(R+1))
WARNING: Large Input/output data, be careful with certain languages.
For the first test case L=1, R=4 and P=4.
Binary representations of numbers of length 4 between 1 and 4 are 0001,0010,0011,0100.
We can easily see that only 3 has equal number of 0′s and 1′s in its binary representation.So ans=1.