Score : $600$ points
Find the number, modulo $998244353$, of integer sequences $A = (A_1, \dots, A_N)$ of length $N$ that satisfy all of the following conditions:
Input is given from Standard Input in the following format:
$N$ $M$ $Q$ $L_1$ $R_1$ $X_1$ $\vdots$ $L_Q$ $R_Q$ $X_Q$
Print the answer.
3 3 2 1 2 2 2 3 3
5
$A = (0, 2, 3), (1, 2, 3), (2, 0, 3), (2, 1, 3), (2, 2, 3)$ satisfy the conditions.
1 1 1 1 1 1
1
6 40000000 3 1 4 30000000 2 6 20000000 3 5 10000000
135282163