{"problem":{"name":"Odd Namori","description":{"content":"You are given a rooted tree $T$ with $N$ vertices labeled from $1$ to $N$. The root is the vertex $1$, and the parent of vertex $i$ $(2 \\leq i \\leq N)$ is $p_i$ $(p_i \\lt i)$. Consider a directed grap","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc070_b"},"statements":[{"statement_type":"Markdown","content":"You are given a rooted tree $T$ with $N$ vertices labeled from $1$ to $N$. The root is the vertex $1$, and the parent of vertex $i$ $(2 \\leq i \\leq N)$ is $p_i$ $(p_i \\lt i)$.\nConsider a directed graph $G$ with $N$ vertices labeled from $1$ to $N$. We call $G$ **good** if it satisfies all of the following conditions (here, let $u \\to v$ denote an edge from vertex $u$ to vertex $v$):\n\n*   Every vertex in $G$ has outdegree $1$.\n*   $G$ has no cycle of even length.\n*   For every $i$ $(2 \\leq i \\leq N)$, $G$ does not contain the edge $i \\to p_i$.\n\nFind the sum, modulo $998244353$, of $2^{(\\text{number of cycles in }G)}$ over all good graphs $G$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 10^5$\n*   $1 \\leq p_i \\lt i$\n*   All values given in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$p_2$ $p_3$ $\\dots$ $p_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc070_b","tags":[],"sample_group":[["2\n1","6\n\nHere are the two possible good graphs:\n\n*   The graph with edges $1 \\to 1$ and $2 \\to 2$.\n*   The graph with edges $1 \\to 2$ and $2 \\to 2$.\n\nThe number of cycles in these graphs are $2$ and $1$, respectively. Thus, the answer is $(2^2 + 2^1) \\bmod{998244353} = 6$."],["3\n1 2","34\n\nFor example, the graph with edges $1 \\to 2$, $2 \\to 3$, and $3 \\to 1$ is a good graph, whose number of cycle is $1$."],["5\n1 2 1 1","3104"],["20\n1 2 2 2 5 3 5 1 7 9 4 6 4 12 8 2 5 16 6","784973196\n\nRemember to find the sum modulo $998244353$."]],"created_at":"2026-03-03 11:01:14"}}