Score : 1000 points
Problem Statement
You are given a simple connected undirected graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge connects vertices Ai and Bi.
Find the number of ways to paint each edge of G in color 1, 2, or 3 so that the following condition is satisfied, modulo 998244353.
- There is a simple path in G that contains an edge in color 1, an edge in color 2, and an edge in color 3.
What is a simple path?
(v1,…,vk+1)(e1,…,ek)- i=j⟹vi=vj;
- edge ei connects vertices vi and vi+1.
## Constraints
-
3≤N≤2×105
-
3≤M≤2×105
-
1≤Ai,Bi≤N
- The given graph is simple and connected.
## Input
The input is given from Standard Input in the following format:
>
N M
>
>
A1 B1
>
>
⋮
>
>
AM BM
## Output
Print the number of ways to paint each edge of
G in color
1,
2, or
3 so that the condition in question is satisfied, modulo
998244353.
```input1
3 3
1 2
1 3
3 2
```
```output1
0
```
Any simple path in
G contains two or fewer edges, so there is no way to satisfy the condition.
```input2
4 6
1 2
1 3
1 4
2 3
2 4
3 4
```
```output2
534
```
```input3
6 5
1 3
4 3
5 4
4 2
1 6
```
```output3
144
```
```input4
6 7
1 2
2 3
3 1
4 5
5 6
6 4
1 6
```
```output4
1794
```$$