#P1093D. Beautiful Graph
Beautiful Graph
No submission language available for this problem.
Description
You are given an undirected unweighted graph consisting of vertices and edges.
You have to write a number on each vertex of the graph. Each number should be , or . The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.
Calculate the number of possible ways to write numbers , and on vertices so the graph becomes beautiful. Since this number may be large, print it modulo .
Note that you have to write exactly one number on each vertex.
The graph does not have any self-loops or multiple edges.
The first line contains one integer () — the number of tests in the input.
The first line of each test contains two integers and () — the number of vertices and the number of edges, respectively. Next lines describe edges: -th line contains two integers , () — indices of vertices connected by -th edge.
It is guaranteed that and .
For each test print one line, containing one integer — the number of possible ways to write numbers , , on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo .
Input
The first line contains one integer () — the number of tests in the input.
The first line of each test contains two integers and () — the number of vertices and the number of edges, respectively. Next lines describe edges: -th line contains two integers , () — indices of vertices connected by -th edge.
It is guaranteed that and .
Output
For each test print one line, containing one integer — the number of possible ways to write numbers , , on the vertices of given graph so it becomes beautiful. Since answers may be large, print them modulo .
Samples
Note
Possible ways to distribute numbers in the first test:
- the vertex should contain , and should contain ;
- the vertex should contain , and should contain ;
- the vertex should contain , and should contain ;
- the vertex should contain , and should contain .
In the second test there is no way to distribute numbers.