HOJOBOROLO, a multinational company, has employees numbered from through . Each employee, except for lower-level employees, has at least one subordinate. Lower-level employees have no subordinate. Each employee, except for the head of the company, has exactly one direct supervisor. Employee number is the head of the company and he is in the highest level. There are teams in the company and employee number leads the -th team. The -th team consists of the team leader (employee number ) and all the direct or indirect subordinates of the team leader.
Now, there will be projects this year for the company. The head will distribute all the projects among the teams. One project will not be given to more than one group.
After completing a project, all the team members associated with the project will get a bonus amount which will be added to their account. If employee number is a team leader then he/she will get a bonus amount and other team members will get a bonus amount of .
You have to tell the final account balance for each employee at the end of this year.
The first line contains an integer , the number of test cases.
The second line contains two integers and , the number of employees and the number of projects.
The third line contains integers , where is the initial account balance of employee number .
Then each of the lines contain two integers and , where there is a connection between and and the connection represents the relation between supervisor and subordinate.
The next lines describe about the project distribution. In each line there are two integers and , the -th team for this project and bonus amount for each subordinates.
It is guaranteed that sum of over all test cases will not be greater than .
For each test case, print integers in a line, the final (at the end of the year) account balance of each employee number from through respectively.
Input | Output |
---|---|
1 6 3 1000 1000 1000 1000 1000 1000 1 2 1 3 1 4 3 6 3 5 1 2000 4 3000 3 1500 | 5000 3000 6000 9000 4500 4500 |
After each query, update of the account balance of each employee is given below (Here, each node represents the corresponding employee and his/her current account balance is written nearby)