import sys input = sys.stdin.readline mod=998244353 T=int(input()) for tests in range(T): A,B,K=list(map(int,input().split())) if B==0: ANS=max(0,A*K) print(ANS%mod) continue if A==0: print(0) continue if B==1: if A<0: ANS=0 else: ANS=A*K print(ANS%mod) if B>1: if A>0: ANS=A*pow(B,K-1,mod)%mod print(ANS%mod) else: ANS=0 print(ANS%mod) continue if B<=-1: if A>0: if (K-1)%2==0: ANS=A*pow(B,K-1,mod)%mod else: ANS=(A+A)*pow(B,K-2,mod)%mod else: if (K-1)%2==1: ANS=-A*pow(B,K-1,mod)%mod else: ANS=(-A-A)*pow(B,K-2,mod)%mod print(ANS%mod)