Codeforces Round 606 (Div. 1, based on Technocup 2020 Elimination Round 4)
D
Tree Elimination
Codeforces
2900
原题
← CE →
翻译中…

Vasya has a tree with $n$ vertices numbered from $1$ to $n$, and $n - 1$ edges numbered from $1$ to $n - 1$. Initially each vertex contains a token with the number of the vertex written on it.

翻译中…

Vasya plays a game. He considers all edges of the tree by increasing of their indices. For every edge he acts as follows:

翻译中…
  • If both endpoints of the edge contain a token, remove a token from one of the endpoints and write down its number.
  • Otherwise, do nothing.
翻译中…

The result of the game is the sequence of numbers Vasya has written down. Note that there may be many possible resulting sequences depending on the choice of endpoints when tokens are removed.

翻译中…

Vasya has played for such a long time that he thinks he exhausted all possible resulting sequences he can obtain. He wants you to verify him by computing the number of distinct sequences modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($2 \leq n \leq 2 \cdot 10^5$) — the number of vertices of the tree.

翻译中…

The next $n - 1$ lines describe edges of the tree. The $i$-th of these lines contains two integers $u_i, v_i$ ($1 \leq u_i, v_i \leq n$) — endpoints of the edge with index $i$. It is guaranteed that the given graph is indeed a tree.

翻译中…

Output

翻译中…

Print a single integer — the number of distinct sequences modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first sample case the distinct sequences are $(1), (2, 1), (2, 3, 1), (2, 3, 4, 1), (2, 3, 4, 5)$.

翻译中…

Int the second sample case the distinct sequences are $(2, 6, 5, 3), (2, 6, 5, 7), (2, 6, 7, 2), (2, 6, 7, 5), (2, 7, 3), (2, 7, 5), (7, 1, 3), (7, 1, 5), (7, 2, 3), (7, 2, 5)$.

翻译中…

样例

Input #1
5
1 2
1 3
1 4
1 5
Output #1
5
InputCopy OutputCopy
Input #2
7
7 2
7 6
1 2
7 5
4 7
3 5
Output #2
10
InputCopy OutputCopy
题目信息
题号
1276D
时间限制
2 s
内存限制
512 MB
标签
动态规划
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。