from sys import stdin def input(): return stdin.readline().rstrip("\n") mod = 998244353 def solve(a, b, k): if b == 0 or b == 1: if a <= 0: return 0 else: return a * k % mod if b > 1: if a <= 0: return 0 # 1 * a + (k-1) * b return a * pow(b, k - 1, mod) % mod if a == 0: return 0 kh = (k - 1) // 2 b2 = b * b if a > 0: return a * pow(b2, kh, mod) % mod if k % 2 == 0: return a * pow(b, k - 1, mod) % mod elif k == 1: return 0 else: return a * pow(b, k - 2, mod) % mod case_t = 1 case_t = int(input()) for _ in [None] * case_t: a, b, k = map(lambda s_: int(s_), input().split()) print(solve(a, b, k) % mod)