Little Q has an apple tree with nn nodes, labeled by 1,2,…,n1,2,…,n. The root of the tree is the 11-th node and the length of each edge is one unit. There are aiai apples on the ii-th node. The price of each apple is one dollar, so if you sell tt apples, you will gain tt dollars.
Skywalkert, a close friend of Little Q, lost most of his money betting on programming contests, so he wants to steal some apples from this apple tree and sell them to make money.
The security system takes pictures of the nodes once per hour using mm cameras. Let's denote d(x,y)d(x,y) as the number of edges on the shortest path from the xx-th node to the yy-th node, and denote set p(x,k)p(x,k) as {y|y in x's subtree and d(x,y)≤k}{y|y in x's subtree and d(x,y)≤k}. Note that x∈p(x,k)x∈p(x,k). The image from the ii-th camera shows the picture of all the nodes in p(xi,ki)p(xi,ki). If the security system detects a change in any of these images, it sounds an alarm, the thief will be caught by Little Q.
Skywalkert is also a gifted hacker. He can lock some cameras so that images from these cameras will never change. Specifically, if he want to lock the ii-th camera, he needs to pay cici dollars to do such a hack.
Please write a program to help Skywalkert make money optimally without being caught.
Input
The first line of the input contains an integer T(1≤T≤10000)T(1≤T≤10000), denoting the number of test cases.
In each test case, there are two integers n,m(1≤n,m≤300000)n,m(1≤n,m≤300000) in the first line, denoting the number of nodes and cameras.
In the second line, there are n−1n−1 integers f2,f3,...,fn(1≤fi<i)f2,f3,...,fn(1≤fi<i), denoting the father of each node.
In the third line, there are nn integers a1,a2,...,an(1≤ai≤109)a1,a2,...,an(1≤ai≤109), denoting the number of apples on each node.
For the next mm lines, each line contains three integers xi,ki,ci(1≤xi≤n,0≤ki≤n,1≤ci≤109)xi,ki,ci(1≤xi≤n,0≤ki≤n,1≤ci≤109), denoting each camera.
It is guaranteed that ∑n≤106∑n≤106 and ∑m≤106∑m≤106.
Output
For each test case, print a single line containing an integer, denoting the maximum amount of dollars Skywalkert can earn.