MOD = 998244353 # Precompute ways for H=2, W>=3 case ways = [0] * (18 + 1) for c in range(19): if c <= 9: ways[c] = c + 1 else: ways[c] = 19 - c def compute_case(W, H, X): if H == 1 and W == 1: return 1 if 0 <= X <= 9 else 0 elif (H == 1 and W == 2) or (W == 1 and H == 2): if X < 0 or X > 18: return 0 if X <= 9: return (X + 1) % MOD else: return (19 - X) % MOD elif (H == 1 and W >= 3) or (W == 1 and H >= 3): return 1 if 0 <= X <= 9 else 0 elif H == 2 and W == 2: def comb(n): if n < 0: return 0 return n * (n-1) * (n-2) // 6 if n >= 3 else 0 total = comb(X + 3) total -= 4 * comb(X + 3 - 10) total += 6 * comb(X + 3 - 20) total -= 4 * comb(X + 3 - 30) total += comb(X + 3 - 40) return total % MOD elif H == 2 or W == 2: if H != 2: W, H = H, W if H != 2: return 0 if X < 0 or X > 36: return 0 res = 0 start = max(0, X - 18) end = min(18, X) for C1 in range(start, end + 1): C2 = X - C1 if C2 < 0 or C2 > 18: continue res = (res + (ways[C1] ** 2) * (ways[C2] ** 2)) % MOD return res else: return 1 if X == 0 else 0 T = int(input()) for _ in range(T): W, H, X = map(int, input().split()) result = compute_case(W, H, X) print(result % MOD)