There are $$$k$$$ undirected graphs $$$G_1,G_2,\dots,G_k$$$. They share the vertex set $$$\{1,2,\dots,n\}$$$, and initially none of them has an edge.
Process $$$q$$$ operations in order. An operation $$$i,u,v$$$ adds an undirected edge between distinct vertices $$$u$$$ and $$$v$$$ in $$$G_i$$$. The same edge may be added more than once, and $$$u$$$ and $$$v$$$ may already be connected in $$$G_i$$$.
After every operation, determine the number of unordered pairs of distinct vertices $$$\{x,y\}$$$ such that $$$x$$$ and $$$y$$$ belong to the same connected component in every one of the $$$k$$$ graphs.
The first line contains an integer $$$T$$$ ($$$1\le T\le 10^4$$$), the number of test cases.
For each test case:
It is guaranteed that the sum of $$$q$$$ over all test cases does not exceed $$$5\times 10^5$$$.
For each test case, print $$$q$$$ lines. The $$$j$$$-th line must contain one integer: the required number of unordered pairs immediately after the $$$j$$$-th operation. If $$$q=0$$$, print no lines for that test case.
23 2 41 1 22 1 21 2 32 2 34 1 31 1 21 3 41 2 3
0 1 1 3 1 2 6
In the first test case, vertices $$$1$$$ and $$$2$$$ become connected in both graphs after the second operation. After the fourth operation, all three pairs of vertices are connected in both graphs.
The second test case has only one graph, so the answer is the number of vertex pairs within its connected components.
| Name |
|---|


