I need help with a problem from Codersbit 2019 held on 1st September.
There are 4 persons W X Y Z and there is one ball. Each person can pass the ball to any one of the rest 3. Initially the ball is with W. What is the probability that after A number of passes the ball will land back at person W. If the probability is p/q the answer should be (p ^ q-1) mod (10^9 + 7).
0<= A <= 10^5
I believe that the value of p = 3 * (A-1) and q = 3 ^ A but was getting WA. What should be the correct approach to this?