we magic tree root tree n vertex the vertex number 1 n Vertex 1 rootThe magic tree give magic fruit the fruit grow vertex tree root each vertex contain piece fruitIt day 0 fruit ripe each fruit ripe single day for fruit give vertex v_j grow day d_j ripe w_j magic juice extract harvest ripethe fruit harvest cut branch tree on day cut branch tree like the part tree cut fall ground collect ripe fruit contain all fruit fall ground ripe discard magic juice collect themformally day erase edge tree whenever tree split multiple connect component you erase component contain root harvest ripe fruit component containedgiven description tree location ripen day juiciness m fruit calculate maximum total magic juice harvest tree