Problem: Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers , find the number of arrays , satisfying the following constraints:
- The length of is ,
- Define an array of length as follows: , , where is the bitwise exclusive-or (xor). After constructing an array , the constraint should hold.
Since the number of possible arrays may be too large, you need to find the answer modulo .
Input Format: The first line contains an integer () denoting the number of test cases in the input.
Each of the next lines contains two integers ().
Note that is not necessary the prime!
Output Format: For each test case, print the number of arrays , satisfying all given constrains, modulo .