from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right from itertools import permutations, combinations, groupby from heapq import heappop, heappush import math, sys input = lambda: sys.stdin.readline().rstrip("\r\n") def printl(li, sep=" "): print(sep.join(map(str, li))) def yn(flag): print(Yes if flag else No) _int = lambda x: int(x)-1 MOD = 998244353 #10**9+7 INF = 1<<60 Yes, No = "Yes", "No" def solve(): A, B, K = map(int, input().split()) if A == 0: print(0) return if 0 <= B <= 1: if A < 0: print(0) else: print(A*K) return if B == -1: if A < 0: print(-A*(K-1)) else: print(A*K) return if B > 1: if A < 0: print(0) else: # A > 0 print(A*pow(B, K-1, MOD)%MOD) else: # B < -1 if A < 0: if K&1: if K == 1: print(0) else: print(-A*2*pow(-B, K-2, MOD)%MOD) else: print(-A*pow(-B, K-1, MOD)%MOD) else: if K&1: print(A*pow(-B, K-1, MOD)%MOD) else: print(A*2*pow(-B, K-2, MOD)%MOD) return for _ in range(int(input())): solve()