#P3235. 「POI2019 R1」Przedszkole

「POI2019 R1」Przedszkole

Description

Source Problem: POI XXVII - I etapPrzedszkole

Each morning the kindergarten teacher hands out toys to the children. To keep everything in order, each of the nn children receives exactly one toy. Each child may either play on their own or in pair together with another child, but only if the two like each other.

The teacher has kk kinds of toys. She is wondering how many different ways there are to distribute the toys among the children in such a way that every two children who like each other receive different kinds (so that they have two kinds to play with should they form a pair).

Input Format

In the first input line, there is a triplet of integers nn, mm, zz, separated by single spaces, which respectively specify: the number of children in the kindergarten, the number of pairs of children who like each other, and the number of queries.

The mm lines that follow specify the pairs of children who like each other: each such line contains two positive integers ai and bi which are the numbers of the two children who like each other. For simplicity, we number children from 11 to nn. No pair appears more than once on input.

Finally, the last zz lines contain the queries: the ii-th of these contains an integer kik_i.

Output Format

Exactly zz lines should be printed to output: the ii-th of these should contain the number of ways the toys can be distributed among the children if there are kik_i kinds. The numbers should be reported modulo 109+710^9 + 7 (i.e., the remainder of division of the actual number by 109+710^9 + 7 should be printed).

4 4 1
1 2
2 3
1 3
3 4
3
12

Additional Samples

See prz/prz*.in and prz/prz*.out for additional samples.

  • Additional Sample 1: n=5,m=10n = 5, m = 10 (all children like each other), two queries for k{5,6}k \in \{5, 6\};
  • Additional Sample 2: n=11,m=40n = 11, m = 40, query for k=15k = 15;
  • Additional Sample 3: n=100,m=15n = 100, m = 15, five queries for random k[10,100]k \in [10, 100];
  • Additional Sample 4: n=100,m=100n = 100, m = 100, the pairs of children who like each other are No. ii and No. i+1i + 1 for 1i<1001 \leq i < 100 as well as No. 100100 and No. 11; three queries for k{5,10,15}k \in \{5, 10, 15\}.

Constraints

The set of tests consists of the following subsets. Within each subset, there may be several tests. Within each subset, at least 50%50\% of the score is awarded for tests in which z=1z = 1.

For all data, it is guaranteed that $1 \le n \le 10^5, 0 \le m \le \min(10^5, n(n-1)/2), 1 \le z \le 1000, 1 \le a_i, b_i \le n, 1 \le k_i \le 10^9$.

Subtask # Additional Constraints Score
11 n 8,k8,z50n \le 8, k \le 8, z \le 50 88
22 n 15n \le 15 2626
33 m24m \le 24 3333
44 Each child likes exactly two other children 3333