There is a rooted tree with n vertices and the root vertex is 1. In each vertex, there is a monster. The hit points of the monster in the i-th vertex is hp_i.
Kotori would like to kill all the monsters. The monster in the i-th vertex could be killed if the monster in the direct parent of the i-th vertex has been killed. The power needed to kill the i-th monster is the sum of hp_i and the hit points of all other living monsters who lives in a vertex j whose direct parent is i. Formally, the power equals to hp_i+∑_the monster in vertex j is alive and i is the direct parent of jhp_j
In addition, Kotori can use some magic spells. If she uses one magic spell, she can kill any monster using 0 power without any restriction. That is, she can choose a monster even if the monster in the direct parent is alive.
For each m=0,1,2,⋯,n, Kotori would like to know, respectively, the minimum total power needed to kill all the monsters if she can use m magic spells.
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first line contains an integer n (2≤n≤2×103), indicating the number of vertices.
The second line contains (n−1) integers p_2,p_3,⋯,p_n (1≤p_i<i), where p_i means the direct parent of vertex i.
The third line contains n integers hp_1,hp_2,⋯,hp_n (1≤hp_i≤109) indicating the hit points of each monster.
It's guaranteed that the sum of n of all test cases will not exceed 2×103.
For each test case output one line containing (n+1) integers a_0,a_1,⋯,a_n separated by a space, where a_m indicates the minimum total power needed to kill all the monsters if Kotori can use m magic spells.