For Binomial Fever problem I used simple geometric progression for:

Test Case r=2:

my code is

‘’’

for r=2

ans = pC2+p^2C2+…

ans = (p(p-1)+p^2(p^2-1)+…+p^n(p^n-1)/2

ans = ((p^2 + p^4 + p^6 + … + p^2n) - (p + p^2 + p^3 +…+ p^n))/2

ans = (G.P of p^2 - G.P of n)/2

‘’’

t = int(input())

m = 998244353

for i in range(t):

n,p,r = map(int,input().split())

a = pow(p,n,m)

b = a*p%m
a = (p*((a-1)

*(b-1))%m)%m*

c = pow(pp-1,m-2,m)

c = pow(p

c2 = pow(2,m-2,m)

if r==2: print((a*(c*c2)%m)%m)

It gave WA, can some explain me why I am getting WA?