xor game

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

Hard8MathCombinatoricsBit manipulationDynamic programmingNo attempts yetTime limit0.5sMemory limit128 MB

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 23112^{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 0u<2310 \le u < 2^{31}.
    • Let numnum be the number on the card currently held. Replace that card with the card that has numunum \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 (0a,b<2310 \le a, b < 2^{31}) and nn (0<n1090 < 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 21=32 \oplus 1 = 3 on it.