Defense Tower

아직 제출이 없습니다시간 제한6초메모리 제한512 MB

문제

In ICPCCamp, there are nn cities conveniently labeled with 1,2,,n1, 2, \dots, n, connected by (n1)(n - 1) bidirectional roads. It is guaranteed that there is exactly one path between any two different cities.

In each city ii, there is a defense tower with power a_ia\_i, built in the order n,(n1),,1n, (n - 1), \dots, 1. The towers are numbered the same as the cities. Therefore, tower nn is the oldest tower while tower 11 is the newest. The effect of tower ii on city jj is defined as eff(i,j)=a_iδ(i,j)\mathit{eff}(i, j) = a\_i - \delta(i, j). Here, δ(i,j)\delta(i, j) is the number of roads between cities ii and jj. The protector of city jj is the tower with maximum effect on it. If several towers have the same effect on a single city, the oldest one is chosen as the protector of this city.

Yuuka issues qq commands to upgrade the power of the defense towers, where the kk-th command is to add d_kd\_k points of power to the tower w_kw\_k. After each command, she would like to know the sum of protectors' labels for all cities. Note that the newly upgraded tower becomes the newest tower automatically.

However, there is a twist. Upgrading a tower is a costly operation. If the tower being upgraded is not even the protector for its own city, or d_k=0d\_k = 0, the upgrade command is ignored.

입력

The input contains zero or more test cases, and is terminated by end-of-file. For each test case:

The first line contains two integers nn and qq (1n,q1051 \leq n, q \leq 10^5).

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \dots, a\_n (0a_i1090 \leq a\_i \leq 10^9).

The ii-th of the following (n1)(n - 1) lines contains two integers u_iu\_i and v_iv\_i which denote a road between cities u_iu\_i and v_iv\_i (1u_i,v_in1 \leq u\_i, v\_i \leq n). It is guaranteed that there is exactly one path between any two different cities.

The kk-th of the last qq lines contains two integers w_kw\_k and d_kd\_k (1w_kn1 \leq w\_k \leq n, 0d_k1090 \leq d\_k \leq 10^9). 

It is guaranteed that both the sum of all nn and the sum of all qq do not exceed 10510^5.

출력

For each test case, output qq integers s_1,s_2,,s_qs\_1, s\_2, \dots, s\_q, where s_ks\_k denotes the sum of protectors' labels after the kk-th command.