#abc294h. [abc294_h]K-Coloring
[abc294_h]K-Coloring
Problem Statement
You are given a simple undirected graph with vertices numbered to and edges numbered to . Edge connects vertex and vertex .
Find the number, modulo , of ways to write an integer between and , inclusive, on each vertex of this graph to satisfy the following condition:
- two vertices connected by an edge always have different numbers written on them.
Constraints
- $0 \\leq M \\leq \\min \\left(30, \\frac{N(N-1)}{2} \\right)$
- The given graph is simple.
Input
The input is given from Standard Input in the following format:
Output
Print the number, modulo , of ways to write integers between and , inclusive, on the vertices to satisfy the condition.
Sample Input 1
4 3 2
1 2
2 4
2 3
Sample Output 1
2
Here are the two ways to satisfy the condition.
- Write on vertices , and write on vertex .
- Write on vertex , and write on vertex .
Sample Input 2
4 0 10
Sample Output 2
10000
All ways satisfy the condition.
Sample Input 3
5 10 5
3 5
1 3
1 2
1 4
3 4
2 5
4 5
1 5
2 3
2 4
Sample Output 3
120
Sample Input 4
5 6 294
1 2
2 4
1 3
2 3
4 5
3 5
Sample Output 4
838338733
Sample Input 5
7 12 1000000000
4 5
2 7
3 4
6 7
3 5
5 6
5 7
1 3
4 7
1 5
2 3
3 6
Sample Output 5
418104233