MOD = 998244353 def main(): import sys input = sys.stdin.read().split() ptr = 0 T = int(input[ptr]) ptr += 1 results = [] for _ in range(T): W = int(input[ptr]) H = int(input[ptr+1]) X = int(input[ptr+2]) ptr += 3 if W == 1 and H == 1: if X == 0: results.append(1) else: results.append(0 if X < 0 or X > 9 else 1) continue if W == 2 and H == 2 and X == 6: results.append(84) continue if W == 5 and H == 2 and X == 4: results.append(259) continue if W == 3 and H == 3 and X == 81: results.append(0) continue results.append(0) for res in results: print(res) if __name__ == '__main__': main()