2021 年东华大学金马程序设计联赛

G. IDEA's Tree
PDF 题面可用
你可以在这里下载。

单点时限: 10.0 sec

内存限制: 256 MB

IDEA has a tree with $n(1\leq n\leq 5000)$ nodes. Now she select a connected subgraph on the tree randomly, please help her calculate the expected size of connected subgraph she select (module $998244353$).

输入格式

There are multiple test cases.

For each test case, in the first line, there is an integer n, denoting the node number of the tree.

Then for the next $n-1$ lines, $i$-th line contains an integer $u$, indicate that there is an edge between $i+1$ and $u$.

输出格式

For each test cases, print the answer in one line.

样例

Input
3
1
1
Output
665496237