{"raw_statement":[{"iden":"problem statement","content":"Find the number, modulo $998244353$, of permutations $P=(P_1,P_2,\\cdots,P_N)$ of $(1,2,\\cdots,N)$ that satisfy all of the following $M$ conditions.\n\n*   The $i$\\-th condition: The maximum among $P_{L_i},P_{L_i+1},\\cdots,P_{R_i}$ is **not** $P_{X_i}$. Here, $L_i$, $R_i$, and $X_i$ are integers given in the input."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 500$\n*   $1 \\leq M \\leq 10^5$\n*   $1 \\leq L_i \\leq X_i \\leq R_i \\leq N$\n*   All input values are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $M$\n$L_1$ $R_1$ $X_1$\n$L_2$ $R_2$ $X_2$\n$\\vdots$\n$L_M$ $R_M$ $X_M$"},{"iden":"sample input 1","content":"3 2\n1 3 2\n1 2 1"},{"iden":"sample output 1","content":"1\n\nOnly one permutation, $P=(1,2,3)$, satisfies the conditions."},{"iden":"sample input 2","content":"5 1\n1 1 1"},{"iden":"sample output 2","content":"0"},{"iden":"sample input 3","content":"10 5\n3 8 4\n3 10 4\n1 7 2\n1 8 3\n3 8 7"},{"iden":"sample output 3","content":"1598400"},{"iden":"sample input 4","content":"15 17\n2 11 9\n2 15 13\n1 14 2\n5 11 5\n3 15 11\n1 6 2\n4 15 12\n3 11 6\n9 13 10\n2 14 6\n10 15 11\n1 8 6\n6 14 8\n2 10 2\n6 12 6\n3 14 12\n2 6 2"},{"iden":"sample output 4","content":"921467228"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}