CF739B Alyona and a tree
Description
Alyona has a tree with $ n $ vertices. The root of the tree is the vertex $ 1 $ . In each vertex Alyona wrote an positive integer, in the vertex $ i $ she wrote $ a_{i} $ . Moreover, the girl wrote a positive integer to every edge of the tree (possibly, different integers on different edges).
Let's define $ dist(v,u) $ as the sum of the integers written on the edges of the simple path from $ v $ to $ u $ .
The vertex $ v $ controls the vertex $ u $ ( $ v≠u $ ) if and only if $ u $ is in the subtree of $ v $ and $ dist(v,u)
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the example test case the vertex $ 1 $ controls the vertex $ 3 $ , the vertex $ 3 $ controls the vertex $ 5 $ (note that is doesn't mean the vertex $ 1 $ controls the vertex $ 5 $ ).