F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Play on Tree

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1736    Accepted Submission(s): 611


Problem Description
Trees are very interesting, so playing on them is also very interesting.One day, Satono Diamond and Kitasan Black were playing a game on a tree.

First, Satono Diamond selected a point as the root of the tree.

Then Kitasan Black began the game. Each round selected a node $x$ and deleted it and its subtree.

Whoever deleted the root node lost.

Kitasan Black wanted to know if she could win, but she didn't know which root node it was, so she assumed that the root node was randomly selected by Satono Diamond.Please tell her the probability of winning.

Please output it modulo $10^9+7$.
 

Input
The input consists of multiple test cases. The first line contains a single integer $T(1 \leq T \leq 3)$ — the number of test cases.

The first line of each test case contains one integer $n$ $(1 \leq n \leq 2\times 10^5)$ — the number of nodes in the tree.

Each of the next ${n-1}$ lines contains three integers $u,v$ $(1 \leq u,v \leq n,u \neq v)$
 

Output
For each query, output an integer in a single line indicating the probability of winning
 

Sample Input
2 2 1 2 3 1 2 1 3
 

Sample Output
1 666666672
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-05 18:06:14, Gzip enabled