XOR operation

2.7

9 votes
Medium, Probablity, Addition Rules, Expectation, Mathematics
Problem

You are provided a number s. In one step, a number a is randomly selected from the interval [0,N] and s is replaced by sa where  is the Bitwise XOR operation. Determine the expected value of s after k steps modulo 109+7.

There are multiple test cases in a single input file.
You can represent the answer as a rational fraction PQ with Q>0. To provide the answer, you should print PQ1mod(109+7).

Input format

  • First line: An integer t denoting the number of test cases 
  • Each test case consists of three integers nk, and s in a single line

Output format

For each test case, print the answer in a new line.

Constraints

1t20000

0n,k,s109

1t20000

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

-

Editor Image

?