#P6662. [POI 2019/2020 R1] Przedszkole / 幼儿园

[POI 2019/2020 R1] Przedszkole / 幼儿园

Background

In the morning at the kindergarten, teachers need to hand out toys to children.

Problem Description

Some children play with toys alone, and some children play in pairs.

Now there are nn children, and these nn children can be grouped into mm pairs.

There are kk types of toys to be handed out to these children. It must be guaranteed that, within each pair, the two children receive different toys.

Find the total number of possible distribution plans.

Because toys need to be handed out on many days, there are zz queries. In these zz queries, nn, mm, and the given pairs stay the same, while kk changes.

Input Format

The first line contains three integers n,m,zn,m,z, representing the number of children, the number of pairs, and the number of queries.
The children are numbered from 11 to nn.
The next mm lines each contain two integers, representing a pair of children.
The next zz lines each contain one integer kk, representing one query.

Output Format

Output zz lines, each containing one integer, representing the number of distribution plans.
The answer should be taken modulo 109+710^9+7.

4 4 1
1 2
2 3
1 3
3 4
3
12
5 10 2
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
4 5
5
6
120
720
11 40 1
8 1
4 1
3 8
2 6
9 8
11 5
2 5
2 1
11 4
10 6
11 10
9 7
10 4
6 9
9 10
2 11
6 7
8 2
10 8
3 6
11 9
1 10
4 3
6 11
3 11
4 5
8 7
10 3
11 7
9 2
8 6
2 3
3 7
8 4
9 5
4 9
7 2
5 10
10 2
6 4
15
142679253

Hint

Sample Explanation

Two additional samples can be found in the attached files sample 1/2.in and sample 1/2.out.

Constraints

This problem uses bundled tests.

  • Subtask 1 (8 pts): n,k8n,k \le 8, z50z \le 50.
  • Subtask 2 (26 pts): n15n \le 15.
  • Subtask 3 (33 pts): m24m \le 24.
  • Subtask 4 (33 pts): each child appears in exactly two pairs.

For 100%100\% of the testdata, 1n1051 \le n \le 10^5, 0mmin(105,n2n2)0 \le m \le \min(10^5,\dfrac{n^2-n}{2}), 1z10001 \le z \le 1000, 1k1091 \le k \le 10^9.

For 50%50\% of the testdata, z=1z=1.

Note

Translated from POI 2019 D Przedszkole.

Translated by ChatGPT 5