{"raw_statement":[{"iden":"problem statement","content":"There is a rooted tree with $N$ vertices numbered $1$ to $N$. Vertex $1$ is the root, and the parent of vertex $i$ ($2\\leq i\\leq N$) is $P_i$.\nYou are given a non-negative integer $r$ and a sequence of non-negative integers $A = (A_1, \\ldots, A_N)$. You can perform the following operation on the sequence any number of times, possibly zero.\n\n*   Choose an $i$ such that $i\\geq 2$ and $A_i \\geq 1$. Replace $A_i$ with $A_i - 1$ and $A_{P_i}$ with $A_{P_i}+r$.\n\nFind the number, modulo $998244353$, of possible final states of the sequence $A$."},{"iden":"constraints","content":"*   $2\\leq N\\leq 300$\n*   $1\\leq P_i \\leq i - 1$ ($2\\leq i\\leq N$)\n*   $0\\leq r \\leq 10^9$\n*   $0\\leq A_i \\leq 10^9$"},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$P_2$ $\\ldots$ $P_N$\n$r$\n$A_1$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"3\n1 1\n2\n1 1 1"},{"iden":"sample output 1","content":"4\n\nThe four possible final states of $A$ are $(1,1,1)$, $(3,0,1)$, $(3,1,0)$, and $(5,0,0)$."},{"iden":"sample input 2","content":"3\n1 2\n1\n1 1 1"},{"iden":"sample output 2","content":"5\n\nThe five possible final states of $A$ are $(1,1,1)$, $(1,2,0)$, $(2,0,1)$, $(2,1,0)$, and $(3,0,0)$."},{"iden":"sample input 3","content":"3\n1 2\n2\n1 1 1"},{"iden":"sample output 3","content":"6\n\nThe six possible final states of $A$ are $(1,1,1)$, $(1,3,0)$, $(3,0,1)$, $(3,2,0)$, $(5,1,0)$, and $(7,0,0)$."},{"iden":"sample input 4","content":"5\n1 1 3 3\n2\n0 1 0 1 2"},{"iden":"sample output 4","content":"48"},{"iden":"sample input 5","content":"5\n1 1 3 3\n123456789\n1 2 3 4 5"},{"iden":"sample output 5","content":"87782255"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}