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

Vertex Deletion

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 314    Accepted Submission(s): 91


Problem Description
Given a tree with $n$ vertices, you can delete any vertex you like. We call a way of deletion beautiful if, in the remaining part of the tree, every vertex has at least one vertex still connected to it. You need to calculate how many ways of deletion are beautiful.

Two ways of deletion are considered the same if the set of the deleted vertex is the same.
 

Input
This problem contains multiple test cases.

The first line contains an integer $T$ indicating the number of test cases.

For each test case, the first line contains one integer $n$ ($1 \leq n \leq 10 ^ 5$).

The next $n - 1$ lines each contains two integers $u$ and $v$ ($1 \leq u, v \leq n,u\neq v$), representing an edge (u, v).

It's guaranteed that $\sum{n} \leq 10 ^ 6$.
 

Output
Output $T$ lines, each line contains an integer indicating the answer.

Since the answer can be very large, you only need to output the answer modulo $998244353$.
 

Sample Input
1 6 1 2 1 3 2 4 2 5 3 6
 

Sample Output
22
 

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-04-20 14:35:37, Gzip enabled