Colony Catastrophe


You are currently living on in a colony on mars. The environment outside is impossible to live in, so the colony is organised as nn habitats connected by n−1n-1 tunnels, (forming a tree). Each of these habitats has a garden which each produce some amount of oxygen.

However, a meteor storm has caused damage to mm habitats, causing them to leak oxygen. You decide to seal off some of the tunnels, and continue to live in some connected section of the colony.

After sealing off the tunnels, what is the maximum oxygen production of the remaining section of the colony.

Input

The first line contains two integers, nn and mm.

The second line contains integers a1,…,ana_1, \dots, a_n, denoting that the ii-th habitat produces aia_i units of oxygen.

The following n−1n-1 lines contain integers u,vu, v, denoting that a tunnel exists between habitat uu and habitat vv.

Finally, the following mm lines contains integers u,lu, l, denoting that habitat uu is leaking ll units of oxygen.

Output

Output an integer, which is the maximum oxygen production of the remaining section of the colony, after sealing off some tunnels.

Constraints

  • 1≤m,u,v≤n≤1051 \le m,u,v \le n \le 10^5
  • 1≤ai,l≤1091 \le a_i, l \le 10^9

Example 1

Input 1
10 5
10 1 10 7 7 3 6 10 1 6 
1 2
1 3
1 4
2 5
2 6
1 7
7 8
8 9
9 10
6 18
10 15
7 6
3 18
3 13
Output 1
36

Example 2

Input
Input 2
10 7
4 8 10 6 9 5 4 5 5 4 
1 2
1 3
3 4
3 5
2 6
6 7
6 8
3 9
8 10
6 16
7 9
2 20
4 10
8 8
6 5
7 13
Input 3
28

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.