to surprise Jamie final boss EheheheJamie give tree n vertex number 1 n initially root tree vertex number 1 also vertex value itJamie give type query tree1 v change tree root vertex number v2 u v x for vertex subtree small size contain u v add x value3 v Find sum value vertice subtree vertex number vA subtree vertex v set vertex v lie short path vertex root tree pay attention subtree vertex change change tree rootshow strength programming Jamie perform query accurately