题目描述
Problem Background
First, you do not need to know anything about virtual trees to solve this problem.
— Even though this is the first problem in the repository with "virtual tree" in its name.
Problem Description
Jq姐姐有一棵以结点 $1$ 为根的树。定义一棵树的点集 $S$ 的非空子集 $s$ 是好的,当且仅当它满足 $\forall i,j \in s, \text{LCA}(i,j) \in s$。What is $\text{LCA}$?
为了让树的形态更加可爱,jq 姐姐打算修剪掉某个以节点 $i$ 为根的子树(也就是在原树里将节点 $i$ 及其子树内节点及其相连的边均删除)。
她有若干个修剪方案但从未实施,你需要求出每种方案实施后这棵树的好的非空子集数量。由于答案可能会很大,请输出其对 $998244353$ 取模的结果。
Input Format
The first line contains an integer $n$ ($n \leq 5 \times 10^5$), representing the number of nodes in the tree.
From the second to the $n$-th line, each line contains two integers $u_i, v_i$, indicating an edge from $u_i$ to $v_i$.
The $(n+1)$-th line contains an integer $m$ ($m \leq 5 \times 10^5$), representing the number of pruning schemes.
The next line contains $m$ integers $q_i$, indicating that the subtree rooted at $q_i$ will be pruned.
Output Format
Output $m$ lines, each containing an integer $k$ representing the number of good non-empty subsets of the original tree after removing the subtree rooted at $q_i$.
Sample Input and Output
Sample Input #1
5
1 2
2 3
2 4
1 5
2
2 5
Sample Output #1
3
13
Sample Input #2
10
1 2
2 3
2 4
1 5
5 6
5 7
7 8
7 10
1 9
3
5 2 8
Sample Output #2
21
66
201
Notes
Explanation of Sample 1: After removing the subtree rooted at node $2$, all $3$ non-empty subsets of the original tree satisfy the property. After removing the subtree rooted at node $5$, out of the $15$ non-empty subsets of the original tree, $\{3,4\}$ and $\{1,3,4\}$ do not satisfy the property.
For the first $10\%$ of the data, $n, m \leq 20$.
For the first $30\%$ of the data, $n, m \leq 2000$.
For $100\%$ of the data, $1 \leq n, m \leq 5 \times 10^5$, $q \in [1, n]$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分