#P2095. Path Killer

Path Killer

题目描述

点击查看pdf

MainKing has a rooted tree with nn nodes, and mm paths on it. And the root of this tree is 11.

The endpoints of the i-th path are ai,bia_i,b_i. All of these paths satisfy a special condition: aia_i is on the path from bib_i to the root.

Now MianKing wants to delete all of these paths. He will do the following operator until all of the paths are deleted: choose an integer xx from [1,n][1,n] randomly and delete all of the paths where xx is on.

MianKing wants you to calculate the expected number of operations he need to do.

It's guaranteed that the answer will converge to some rational number.

If the answer is irreducible fraction fracxy\\frac{x}{y}, you need to output an integer dd in [0,998244352][0,998244352] which satisfies dy mod 998244353=xd*y~mod~998244353=x. It's guaranteed that y mod 998244353 eq0y~mod~998244353\ eq 0

输入格式

The first line has two integers n,mn,m.

The second line has n1n-1 integers, the i-th integer denotes the father node of node i+1i+1

Then there are mm lines, the i-th line has two integers ai,bia_i,b_i.

1leqn,mleq3001\\leq n,m\\leq 300

Let faifa_i denote the father node of node ii. Then 0ltfailti0 \\lt fa_i \\lt i for iin[2,n]i \\in [2,n]

1leqaileqbileqn1\\leq a_i\\leq b_i\\leq n. It's guaranteed that aia_i is on the path from bib_i to the root.

输出格式

Output the answer.

样例

3 3 
1 1 
1 2 
3 3 
1 1 

499122181 

提示

Form 2020ICPC济南站