{"problem":{"name":"Directed Tree","description":{"content":"Given is a directed tree with $N$ vertices numbered $1$ through $N$. Vertex $1$ is the root of the tree. For each integer $i$ such that $2 \\leq i \\leq N$, there is a directed edge from Vertex $p_i$ to","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc121_e"},"statements":[{"statement_type":"Markdown","content":"Given is a directed tree with $N$ vertices numbered $1$ through $N$.\nVertex $1$ is the root of the tree. For each integer $i$ such that $2 \\leq i \\leq N$, there is a directed edge from Vertex $p_i$ to $i$.\nLet $a$ be the permutation of $(1, \\ldots, N)$, and $a_i$ be the $i$\\-th element of $a$.\nAmong the $N!$ sequences that can be $a$, find the number of sequences that satisfy the following condition, modulo $998244353$.\n\n*   Condition: For every integer $i$ such that $1 \\leq i \\leq N$, Vertex $i$ is unreachable from Vertex $a_i$ by traversing **one or more** edges.\n\n## Constraints\n\n*   All values in input are integers.\n*   $1 \\leq N \\leq 2000$\n*   $1 \\leq p_i < i$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$p_{2}$ $\\cdots$ $p_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc121_e","tags":[],"sample_group":[["4\n1 1 3","4"],["30\n1 1 3 1 5 1 1 1 8 9 7 3 11 11 15 14 4 10 11 12 1 10 13 11 7 23 8 12 18","746746186\n\n*   Remember to print the count modulo $998244353$."]],"created_at":"2026-03-03 11:01:14"}}