8663: Average Replacement

内存限制:512 MB 时间限制:6 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

There are n people in a group and m pairs of friends among them. Currently, each person writes an integer on his hat. They plan to play the following game many times: everyone replaces his number on his hat with the average number of his number and all of his friends' numbers. That is, if before the game the person has a0 written on his hat and a total of k friends, each having number a1,...,ak, then after the game the number on his hat becomes 

(a0++ak  )/ k+1

. Note that numbers may become non-integers.

It can be proved that by playing more and more games, each number converges to a certain value. Given the initial numbers written on the hats, your task is to calculate these values.

输入格式

The first line contains the number of test cases T(1T100).

For each test case, the first line contains two integers n,m(1n,m105) .

The second line contains n integers a1,a2,,an (1ai108) , indicating the number on each hat.

Each of the following mm lines contains two integers u,v (1u,vn) , indicating a pair of friends.

It's guaranteed that there are no self-loop or multiple edges on the graph, and there are at most 2020 test cases such that n > 1000 or m>1000.

输出格式

For each test case, output n integers in n lines, indicating the value of each person at last, and the result are reserved with 6 digits after the decimal point.

输入样例 复制

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

输出样例 复制

1.500000
1.500000
1.500000
1.500000
3.500000 
3.500000