| TheForces Round #31 (Div2.9-Forces) |
|---|
| Закончено |
You will be given a tree containing $$$n$$$ nodes. An unordered pair $$$(u,v)$$$ is called a Super Pair if it satisfies the following conditions:
Your task is to calculate the number of Super Pairs.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^{4}$$$). The description of the test cases follows.
The first line of each testcase contains a single integer $$$n$$$ $$$(2 \le n \le 10^{5})$$$ — the number of nodes in the given tree.
The next $$$n-1$$$ lines contain two integers $$$u,v$$$ $$$(1 \le u,v \le n, u≠v)$$$ — there is an edge connecting $$$u$$$ and $$$v$$$.
It is guaranteed that the sum of $$$n$$$ over all testcases doesn't exceed $$$10^{5}$$$.
For each testcase, print a single integer — the number of Super Pairs.
322 141 23 11 461 21 31 44 55 6
0 3 7
| Название |
|---|


