{"raw_statement":[{"iden":"problem statement","content":"Print the number of sequences $a$ that are permutations of $(1, 2, 3, \\dots, N)$ and satisfy the following condition:\n\n*   for every integer $i$ such that $1 \\le i \\le M$, at most $Z_i$ numbers among $a_1, a_2, a_3, \\dots, a_{X_i}$ are less than or equal to $Y_i$ ."},{"iden":"constraints","content":"*   $2 \\le N \\le 18$\n*   $0 \\le M \\le 100$\n*   $1 \\le X_i \\lt N$\n*   $1 \\le Y_i \\lt N$\n*   $0 \\le Z_i \\lt N$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$X_1$ $Y_1$ $Z_1$\n$X_2$ $Y_2$ $Z_2$\n$X_3$ $Y_3$ $Z_3$\n$\\hspace{23pt} \\vdots$\n$X_M$ $Y_M$ $Z_M$"},{"iden":"sample input 1","content":"3 1\n2 2 1"},{"iden":"sample output 1","content":"4\n\nThe four sequences $a$ satisfying the condition are:\n\n*   $(1, 3, 2)$\n*   $(2, 3, 1)$\n*   $(3, 1, 2)$\n*   $(3, 2, 1)$\n\n$(1, 2, 3)$ and $(2, 1, 3)$ violate the condition, since each of them has two numbers less than or equal to $2$ among $a_1, a_2$."},{"iden":"sample input 2","content":"5 2\n3 3 2\n4 4 3"},{"iden":"sample output 2","content":"90"},{"iden":"sample input 3","content":"18 0"},{"iden":"sample output 3","content":"6402373705728000"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}