Bobo recently obtained a (undirected) graph $$$G=(V, E)$$$. He noticed that each edge of this graph is colored either red or blue, and the maximum degree of this graph is not greater than $$$3$$$.
Now, Bobo wonders how many nonempty induced subgraphs $$$G[S]=(S, E')$$$ of $$$G$$$ are there, such that the two following conditions are satisfied:
As the answer might be too large, you need to output the result modulo $$$998\,244\,353$$$ (a prime number).
Refer to the note section for formal definitions of the underlined items and more illustrations.
The first line contains two integers $$$n$$$ $$$(1\leq n\leq 10^5)$$$ and $$$m$$$ $$$(0\leq m\leq 1.5\times 10^5)$$$, denoting the number of vertices and edges in the graph $$$G$$$, respectively.
Then $$$m$$$ lines follows, each line containing three integers $$$u,v,c$$$ $$$(1\leq u,v\leq n,u\neq v,c\in \{0,1\})$$$, denoting there is an edge $$$(u,v)$$$, with color red if $$$c=0$$$ and color blue otherwise.
It is guaranteed that the maximum degree of $$$G$$$ is at most $$$3$$$, and no two edges with the same color connect the same pair of vertices. Please be aware that multiple edges in $$$G$$$ with different colors may still exist.
Output an integer in a line, denoting the number of induced subgraphs satisfying the required conditions, taken modulo $$$998\,244\,353$$$.
3 41 2 01 3 12 3 02 3 1
5
4 61 2 02 3 03 4 01 4 12 4 11 3 1
5
Here, we provide formal definitions of some underlined items in the statement.
The following picture lists the graph $$$G=(V, E)$$$ and all its seven nonempty induced subgraphs for the first sample test. Here, solid lines represent the red edge, while the dashed lines represent the blue ones. Five nonempty induced subgraphs satisfy the required condition, which are $$$G[\{1\}], G[\{2\}], G[\{3\}], G[\{2,3\}]$$$ and $$$G[\{1,2,3\}]$$$, respectively.