I need help with a problem from Codersbit 2019 held on 1st September.

There are 4 persons

W X Y Zand there isoneball. Each person can pass the ball to any one of the rest 3. Initially the ball is with W. What is the probability that afterAnumber of passes the ball will land back at personW. 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?