This page is still under construction.

Parts of this page are still being built. What you see may change.

xor game

Time limit0.5sMemory limit128 MB

Summary
Count sequences of n xor masks (each below 2^31) that carry a to b, modulo 1e9+7.
Level

Hard8 of 10

Topics
Math, Combinatorics, Bit manipulation, Dynamic programming
Solved
No attempts yet

Problem

chogahui05 plays an xor game. The game runs for nn turns, and there is an unlimited supply of cards for every integer from 00 to 231−12^{31} - 1. The rules are the following.

  • chogahui05 starts holding the card with the integer aa on it.
  • On every turn chogahui05 must do the following.
    • Pick one integer uu with 0≤u<2310 \le u < 2^{31}.
    • Let numnum be the number on the card currently held. Replace that card with the card that has num⊕unum \oplus u on it. Here ⊕\oplus is the bitwise exclusive or.

When the game ended, the number on the card chogahui05 held was bb.

Find the number of possible game processes modulo 10000000071000000007 (109+710^9 + 7). Two processes are different when the integer uu picked on some turn is different.

Input

The first line contains the integers aa, bb (0≤a,b<2310 \le a, b < 2^{31}) and nn (0<n≤1090 < n \le 10^9), separated by spaces.

Output

Print on the first line the number of possible game processes modulo 10000000071000000007.

Hint

Take a=2a = 2, b=3b = 3, n=1n = 1. There is only one turn, so the only possibility is picking u=1u = 1 and replacing the card with the one that has 2⊕1=32 \oplus 1 = 3 on it.

Examples2

  1. Example 1

    Input
    2 3 1
    
    Expected output
    1
    
  2. Example 2

    Input
    0 0 2
    
    Expected output
    147483634