{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eThere are $N$ blanks arranged in a row. The blanks are numbered $ 1, 2, \\ldots , N $ from left to right.\u003cbr\u003eTom is filling each blank with one number in $\\{0, 1, 2, 3\\}$. According to his thought, the following $M$ conditions must all be satisfied. The $i_{th}$ condition is:\u003cbr\u003eThere are exactly $x_i$ different numbers among blanks $\\in [l_i,r_i]$.\u003cbr\u003eIn how many ways can the blanks be filled to satisfy all the conditions? Find the answer modulo $998244353$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T(1\\le T \\le 15)$, denoting the number of test cases.\u003cbr\u003eIn each test case, there are two integers $n(1 \\le n \\le 100)$ and $m(0 \\le m \\le 100)$ in the first line, denoting the number of blanks and the number of conditions.\u003cbr\u003eFor the following $m$ lines, each line contains three integers $l, r$ and $x$, denoting a condition$(1 \\le l \\le r \\le n$, $1 \\le x \\le 4)$. "}},{"title":"Output","value":{"format":"HTML","content":"For each testcase, output a single line containing an integer, denoting the number of ways to paint the blanks satisfying all the conditions modulo $998244353$."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n1 0\r\n4 1\r\n1 3 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n96\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}