#P9036. 「KDOI-04」挑战 NPC Ⅲ
「KDOI-04」挑战 NPC Ⅲ
Background

Problem Description
Xiao S has a great dream: to prove that .
One day, after learning that the maximum independent set problem on general graphs is an NPC problem, he decided to solve it.
Of course, Xiao S is too weak to solve it, so he asks you for help:
Given an undirected graph with vertices and edges, find the number of independent sets in whose size is exactly . Since the answer may be very large, output it modulo .
Xiao S does not like multiple test cases, because he lost points in NOIp due to multiple test cases, so this problem contains multiple groups of testdata.
Input Format
This problem contains multiple groups of testdata.
The first line contains a positive integer , the number of test cases.
For each test case, the first line contains three positive integers .
The next lines each contain two positive integers , representing an edge.
It is guaranteed that there are no self-loops in the graph, but there may be multiple edges.
Output Format
For each test case, output one line with one positive integer, the number of independent sets that meet the requirement, modulo .
3
4 6 1
1 2
1 3
1 4
2 3
2 4
3 4
4 6 3
1 2
1 3
1 4
2 3
2 4
3 4
8 13 5
1 2
7 8
1 3
2 5
3 8
6 8
4 7
5 6
5 7
5 8
6 7
1 8
3 5
0
4
8
Hint
[Sample Explanation]
For test cases and , the graph is a complete graph. It is easy to see that the maximum independent set of a complete graph has size , and each single vertex forms an independent set. Therefore, the answer for test case is , and the answer for test case is .
For test case , the undirected graph is as follows:

All independent sets of size are:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- 。
[Constraints]
This problem uses bundled tests.

For of the data, it is guaranteed that , , , , .
Also, for each test point:
Let , i.e. the maximum value of among all test cases in this test point.
- If , then ;
- If , then ;
- If , then ;
- If , then 。
Translated by ChatGPT 5