 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

# Bracket Sequences on Tree

Time Limit: 40000/20000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 716    Accepted Submission(s): 193

Problem Description
Cuber QQ knows about DFS on an undirected tree, he's sure that you are familiar with it too. In case you are not, Cuber QQ is delighted to share with you a snippet of pseudo code:

function dfs(int cur, int parent):  print(()  for all nxt that cur is adjacent to:    dfs(nxt, cur)  print())

You might notice that Cuber QQ print a "(" when entering a node, and a ")" when leaving a node. So when he finishes this DFS, in his console, he will see a bracket sequence of length $2n$, where $n$ is the number of vertices in the tree.

Obviously, if the tree is undirected and the nodes are unlabelled (meaning that all the nodes are treated equally), you can get a lot of different bracket sequences when you do the DFS. There are two reasons accounting for this. Firstly, when you are at cur, you can follow any permutation of the nodes that cur is adjacent to when you visit nxt. Secondly, the entrance to the tree, that is the root, is undeterministic when you start your DFS.

So Cuber QQ couldn't help wondering how many distinct bracket sequences he can get possibly. As the answer can be very large, output it modulo $998~244~353$.

Input
The first line of the input consists of one integer $t$ ($1 \le t \le 10^5$), which is the number of the test cases.

For each test case, the tree is given in a standard format, which you might be very familiar with: first line $n$ ($1 \le n \le 10^5$), the size of tree; then $n-1$ lines, each consisting of two space-separated integers $u$, $v$ ($1 \le u, v \le n$, $u \ne v$), denoting an edge.

The sum of $n$ from all test cases does not exceed $3.2 \times 10^6$.

Output
For each test case, output the answer in one line.

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

Sample Output
2
4
8

Source

Statistic | Submit | Discuss | Note
 Home | Top Hangzhou Dianzi University Online Judge 3.0 Copyright © 2005-2023 HDU ACM Team. All Rights Reserved. Designer & Developer : Wang Rongtao LinLe GaoJie GanLu Total 0.000000(s) query 1, Server time : 2023-06-10 02:01:50, Gzip enabled Administration