MOD=998244353 N=9 pows=[] inv=[1,1] for i in range(2,1000): inv.append(MOD-(MOD//i)*inv[MOD%i]%MOD) xmax=81 dp=[[[0]*(xmax+1) for i in range(101)] for _ in range(101)] dp2=[[] for _ in range(xmax+1)] for X in range(0,xmax+1): for min_e in range(min(X + 1, N + 1)): for max_e in range(min_e, min(X + 1, N + 1)): for min_o in range(min(X + 1, N + 1)): for max_o in range(min_o, min(X+1, N + 1)): for a00 in range(min(X + 1, N + 1)): upper_o = min([N - a00 + min_e, X - a00 - max_o, N]) lower_o = max([-a00 + max_e, X - a00 - N - min_o, 0]) upper_e = min([N + a00 - max_e, a00 + min_o, N]) lower_e = max([a00 - min_e, -N + a00 + max_o, 0]) if upper_o - lower_o < 0 or upper_e - lower_e < 0: continue for pair0 in [[inv[max_e-min_e+1],max_e-min_e+1],[-2*inv[max_e-min_e],max_e-min_e],[inv[max(0,max_e-min_e-1)],max(0,max_e-min_e-1)]]: for pair1 in [[1,max_o-min_o+1],[-2,max_o-min_o],[1,max(0,max_o-min_o-1)]]: dp[(upper_o-lower_o+1)*(upper_e-lower_e+1)][pair0[1]*pair1[1]][X]+=inv[upper_e-lower_e+1]*pair0[0]%MOD*pair1[0]%MOD dp[(upper_o-lower_o+1)*(upper_e-lower_e+1)][pair0[1]*pair1[1]][X]%=MOD for X in range(xmax+1): for a in range(101): for b in range(101): if dp[a][b][X]!=0: dp2[X].append((a,b,dp[a][b][X])) for n in range(101): a=[1] for i in range(301): a.append(a[-1]*n%MOD) pows.append(a) def solvesub(W,H,X): ans=0 if H==2: cnt=[0]*(2*N+1) for i in range(0,N+1): for j in range(0,N+1): cnt[i+j]+=1 for a in range(2*N+1): b=X-a if b<0 or b>2*N: continue ans+=pow(cnt[a],W//2)*pow(cnt[b],(W+1)//2) ans%=MOD print(ans) return elif W==2: return solvesub(H,W,X) for v in dp2[X]: ans+=v[2]*pows[v[0]][W//2]%MOD*pows[v[1]][H//2]%MOD if ans>=MOD: ans-=MOD print(ans) def solve(W,H,X): if W%3>H%3: W,H=H,W if (W%3==0 and H%3==0) or (W%3==0 and H%3==1) or (W%3==1 and H%3==1): print(int(X<=N)) elif W%3==0 and H%3==2: d=min(N,X)-max(0,X-N)+1 d=max(0,d) print(pow(d,W//3,MOD)) elif W%3==1 and H%3==2: d=min(N,X)-max(0,X-N)+1 d=max(0,d) print(pow(d,(W+2)//3,MOD)) elif W%3==2 and H%3==2: solvesub((W+1)//3*2,(H+1)//3*2,X) else: raise Exception def run(): T=int(input()) for t in range(T): W,H,X=map(int,input().split()) solve(W,H,X) run()