#abc199f. [abc199_f]Graph Smoothing

[abc199_f]Graph Smoothing

Problem Statement

We have a simple undirected graph with NN vertices and MM edges. The vertices are numbered 11 through NN and the edges are numbered 11 through MM.
Edge ii connects Vertex XiX_i and Vertex YiY_i. Initially, Vertex ii has an integer AiA_i written on it.
You will do the following operation KK times:

  • Choose one from the MM edges uniformly at random and independently from other choices. Let xx be the arithmetic mean of the numbers written on the two vertices connected by that edge. Replace each number written on those vertices with xx.

For each vertex ii, find the expected value of the number written on that vertex after KK operations, and print it modulo (109+7)(10^9 + 7) as described in Notes.

Notes

When printing a rational number, first, represent it as a fraction fracyx\\frac{y}{x}, where xx and yy are integers and xx is not divisible by (109+7)(10^9+7) (under the Constraints of this problem, such a representation is always possible).
Then, print the only integer zz between 00 and (109+6)(10^9+6) (inclusive) such that xzequivypmod109+7xz \\equiv y \\pmod {10^9+7}.

Constraints

  • 2leNle1002 \\le N \\le 100
  • 1leMlefracN(N1)21 \\le M \\le \\frac{N(N - 1)}{2}
  • 0leKle1090 \\le K \\le 10^9
  • 0leAile1090 \\le A_i \\le 10^9
  • 1leXileN1 \\le X_i \\le N
  • 1leYileN1 \\le Y_i \\le N
  • The given graph is simple.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM KK A1A_1 A2A_2 A3A_3 dots\\dots ANA_N X1X_1 Y1Y_1 X2X_2 Y2Y_2 X3X_3 Y3Y_3 hspace15ptvdots\\hspace{15pt} \\vdots XMX_M YMY_M

Output

Print NN lines.
The ii-th line should contain the expected value of the number written on that vertex after KK operations, modulo (109+7)(10^9 + 7), as described in Notes.


Sample Input 1

3 2 1
3 1 5
1 2
1 3

Sample Output 1

3
500000005
500000008
  • If Edge 11 is chosen in the only operation: the vertices written on Vertices 1,2,31, 2, 3 will be 2,2,52, 2, 5, respectively.
  • If Edge 22 is chosen in the only operation: the vertices written on Vertices 1,2,31, 2, 3 will be 4,1,44, 1, 4, respectively.

Thus, the expected values of the numbers written on Vertices 1,2,31, 2, 3 are 3,frac32,frac923, \\frac{3}{2}, \\frac{9}{2}, respectively.
If we express them modulo (109+7)(10^9 + 7) as described in Notes, they will be 3,500000005,5000000083, 500000005, 500000008, respectively.


Sample Input 2

3 2 2
12 48 36
1 2
1 3

Sample Output 2

750000036
36
250000031
  • If Edge 11 is chosen in the 11-st operation: The numbers written on Vertices 1,2,31, 2, 3 will be 30,30,3630, 30, 36, respectively.
    • If Edge 11 is chosen in the 22-nd operation: The numbers written on Vertices 1,2,31, 2, 3 will be 30,30,3630, 30, 36, respectively.
    • If Edge 22 is chosen in the 22-nd operation: The numbers written on Vertices 1,2,31, 2, 3 will be 33,30,3333, 30, 33, respectively.
  • If Edge 22 is chosen in the 11-st operation: The numbers written on Vertices 1,2,31, 2, 3 will be 24,48,2424, 48, 24, respectively.
    • If Edge 11 is chosen in the 22-nd operation: The numbers written on Vertices 1,2,31, 2, 3 will be 36,36,2436, 36, 24, respectively.
    • If Edge 22 is chosen in the 22-nd operation: The numbers written on Vertices 1,2,31, 2, 3 will be 24,48,2424, 48, 24, respectively.

Each of these four scenarios happen with probability frac14\\frac{1}{4}, so the expected values of the numbers written on Vertices 1,2,31, 2, 3 are $\\frac{123}{4}, \\frac{144}{4} (=36), \\frac{117}{4}$, respectively.


Sample Input 3

4 5 1000
578 173 489 910
1 2
2 3
3 4
4 1
1 3

Sample Output 3

201113830
45921509
67803140
685163678