As a retired contestant, Colin hopes that all participants will always have a young heart and an eternal love for algorithms and competitive programming.
I remember what someone said to me a long time ago, "The path you choose, even if you walk on your knees, you have to finish it". Friends, although the world is getting more and more impetuous, as long as we can persist in our efforts for the sake of our once pure dreams and moving motives, we can remain true to ourselves all the way, no matter what others do. As a retired contestant, Colin hopes that all participants will always have a young heart and an eternal love for algorithms and competitive programming. Given a tree T T consisting of n n vertices (indexed from 1 1 to n n). Vertex 1 1 is the root. We define that vertex u u is an ancestor of vertex v v if and only if u u is on the path from v v to the root. Then we define subtree_u subtree u as the set of all vertices v v satisfies that u u is an ancestor of v v . Now Colin and Eva give each node u u two integer weights c_u,e_u c u ,e u , then we define : ans_u=sum_{xin subtree_u}sum_{yin subtree_u} min{|c_x-c_y|,|e_x-e_y|} mod 10^9+7 ans u =∑ x∈subtree u ∑ y∈subtree u min{∣c x −c y ∣,∣e x −e y ∣}mod10 9 +7 Please calculate ans_u ans u for each vertex uin [1, n] u∈[1,n] .