{"raw_statement":[{"iden":"problem statement","content":"Takahashi has an $N \\times N$ grid. The square at the $i$\\-th row and the $j$\\-th column of the grid is denoted by $(i,j)$. Particularly, the top-left square of the grid is $(1,1)$, and the bottom-right square is $(N,N)$.\nAn integer, $0$ or $1$, is written on $M$ of the squares in the Takahashi's grid. Three integers $a_i,b_i$ and $c_i$ describe the $i$\\-th of those squares with integers written on them: the integer $c_i$ is written on the square $(a_i,b_i)$.\nTakahashi decides to write an integer, $0$ or $1$, on each of the remaining squares so that the condition below is satisfied. Find the number of such ways to write integers, modulo $998244353$.\n\n*   For all $1\\leq i < j\\leq N$, there are even number of $1$s in the square region whose top-left square is $(i,i)$ and whose bottom-right square is $(j,j)$."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 10^5$\n*   $0 \\leq M \\leq min(5 \\times 10^4,N^2)$\n*   $1 \\leq a_i,b_i \\leq N(1\\leq i\\leq M)$\n*   $0 \\leq c_i \\leq 1(1\\leq i\\leq M)$\n*   If $i \\neq j$, then $(a_i,b_i) \\neq (a_j,b_j)$.\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$a_1$ $b_1$ $c_1$\n$:$\n$a_M$ $b_M$ $c_M$"},{"iden":"sample input 1","content":"3 3\n1 1 1\n3 1 0\n2 3 1"},{"iden":"sample output 1","content":"8\n\nFor example, the following ways to write integers satisfy the condition:\n\n101   111\n011   111\n000   011"},{"iden":"sample input 2","content":"4 5\n1 3 1\n2 4 0\n2 3 1\n4 2 1\n4 4 1"},{"iden":"sample output 2","content":"32"},{"iden":"sample input 3","content":"3 5\n1 3 1\n3 3 0\n3 1 0\n2 3 1\n3 2 1"},{"iden":"sample output 3","content":"0"},{"iden":"sample input 4","content":"4 8\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1"},{"iden":"sample output 4","content":"4"},{"iden":"sample input 5","content":"100000 0"},{"iden":"sample output 5","content":"342016343"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}