Some person is given a bag consisting of N distinct balls, represented by an array A of size N, where the
He (the player) then notes the product of all numbers written on the balls picked, Soon, though he realizes that the number formed is too big, so he only considers the product Mod a given prime P. Let's call the product of the integers written on the picked balls Mod P as Z.
Considering that the probability of picking each ball is the same for each of the K picks, you need to find the Expected Value of Z. Let the answer be an irreducible fraction
Input Format:
The first line consists of 3 space separated integers N ,P and K. The next line consists of N space separated integers , where the
Output Format :
Print the expected value of Z.
Constraints :
P is prime.
It can be proved, that for the following constraints
2 5 2 2 3
499122179
Note that in the sample, for each pick among the
So, the answer is
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor