Milk has created an account in the newly launched social network Coffeebook. However, she cannot decide on a password for her account. So she’s asked Mocha for help (don’t ask me why she trusts Mocha this much).
Mocha has decided to make the process interesting for himself. At each step, he applies the following procedure to come up with a random number.
He creates a non-empty array of at most integers. Formally, .
The array elements should be positive integers at most . Formally, for each .
Each element of the array (except the first one) should be divisible by the previous element. Formally, should hold for each .
After creating such an array, Mocha raises the last element of the array to the power . This gives him a random number.
Mocha doesn’t want to bore himself with the same array over and over again. So at each step, he creates a new array (satisfying the above conditions), an array he hasn’t created before. He stops only when he runs out of arrays satisfying the above conditions. Then he adds up all the powers he’s extracted out of these arrays and adds them up. The result, modulo , is the password he’ll suggest to Milk.
However, soon after coming up with this plan, Mocha realizes that it will take him a long time to go through all possible arrays. He can’t do it on his own. Can you help him?
The only line of input will contain three space-separated positive integers — the limit on the size of the array, — the limit on the array elements, — the power Mocha raises the last element of each array to.
These integers satisfy and .
Print a single line containing the password, which is the sum (modulo ) of the last elements of all possible arrays satisfying the aforementioned conditions, raised to the power .
Input | Output |
---|---|
1 3 0 | 3 |
There are only three possible arrays in this case: . The power to raise to is . So the password would be . |
Input | Output |
---|---|
2 2 3 | 26 |
There are five possible arrays: . The power to raise to is . So the password would be . |
Input | Output |
---|---|
314 15 92 | 168177682 |
Remember to reduce the result modulo . |