| Tishreen + SVU CPC 2023 |
|---|
| Finished |
After Da7doo7 got fired again, he decided to count things for a living. Then, he struggled with this problem, so he called you for help.
You are given a tree consisting of $$$n$$$ nodes.
Your task is to find the sum of $$$GCN$$$ over all different unordered pairs of distinct sets in the given tree, modulo $$$10^9+7$$$.
The first line of the input contains an integer $$$T$$$ $$$(1\le T\le 10^5)$$$ denoting the number of test cases.
The first line of each test case contains an integer $$$n$$$ $$$(2\le n \le 5\cdot 10^5)$$$ — the number of nodes in the tree.
The second line of each test case contains $$$n-1$$$ integers $$$p_2, \ldots, p_n$$$ $$$(1\le p_i \le n)$$$ — indicating that there is an edge between nodes $$$i$$$ and $$$p_i$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5\cdot 10^5$$$.
For each test case, print the answer in a single line.
2 4 1 2 3 4 1 1 1
26 24
| Name |
|---|


