an orient weight forest acyclic weight digraph vertex edge goesThe root vertex v orient weight forest vertex edge goes reach vertex v move edge weight orient forest we denote root vertex v rootvthe depth vertex v sum weight path pass vertex v root Lets denote depth vertex v depthvlet consider process construct weight direct forest Initially forest contain vertex vertex add sequentially Overall n perform operation add the ith i0 add operation describe set number kv1x1v2x2 vkxk mean add vertex number k edge graph edge vertex rootv1 vertex weight depthv1x1 edge vertex rootv2 vertex weight depthv2x2 if k0 vertex add graph add edgesYour task like give operation add vertex calculate sum weight edge forest result application define operation modulo 1000000007 1097