Can anyone please help me in one problem?

Problem: You are given an undirected connected graph, and Q queries, in each query you will be given a vertex 'v' and output for each query should be v(v-1)/2 with remains component after removal of vertex 'v'. When removing node v, the subtree of v's child will be disconnected from the rest of the graph and also separate from the main graph. Each of the part of the graph after removing one node perform this v(v-1)/2 where v is the count of the total connected component this part.

Now you have to minimize the pairwise connectivity after removing each node.

nodes <= 20^5; queries <= 20^5 (Queries are independent).