A simple connected graph n n Rasi has given you. At first, the color of all vertices…
- User
A simple connected graph n n Rasi has given you. At first, the color of all vertices except two vertices r r and b b is white. Ross r r is red and there is a red bead on it. Ross b b is black and has a black bead on it.
Every second, one of the two colors black and red is randomly selected and for each bead of the selected color, which for example is at the top v v is located in all the neighboring vertices of the vertex v v A new bead of the same color is placed in the graph. If the vertex where the new bead is placed is white, the color of the vertex will be the color of that bead, otherwise the color of the vertex will not change.
How many different colors can the graph vertices have at the end of this operation, when all the vertices are colored? Two colorings are different if the color of a vertex is different in those two colorings.
input In the first line, input four natural numbers n n and m m and r r and b b, the number of graph vertices, the number of graph edges, and the number of vertices, respectively r r and vertex number b b, has come. in each of m m next line of two natural numbers v i v i and u i u i It is said that it indicates the presence of an edge between two vertices v i v i and u i u i is in the graph. The given graph is simple and connected. 2 ≤ n ≤ 100
000 2≤n≤100 000 1 ≤ m ≤ m i n ( ( n 2 ) , 200
000 ) 1≤m≤min(( 2 n ), 200 000) 1 ≤ r , b ≤ n 1 ≤ r, b ≤ n r ≠ b r =b 1 ≤ v i , u i ≤ n 1≤v i ,u i ≤n
output In the only remaining output line, count the number of different colorings of the graph at the end of the operation 1 0 9 + 7 10 9 Print +7.
Sub-issues Constraint score subproblem 17 n ≤ 20 n≤20 226 n ≤ 1
000 n≤1 000 3 57 without additional restrictions Example Sample entry 1 4 3 2 3 1 2 2 3 3 4 Plain text Sample output 1 3 Plain text Sample input 2 6 6 1 6 1 2 2 3 2 4 3 5 4 5 5 6 Plain text Sample output 2 4 Plain text Sample entry 3 8 9 1 2 1 3 3 2 1 4 4 5 5 2 1 6 6 7 7 8 8 2 Plain text Sample output 3 8
- Assistant