{"problem":{"name":"Awkward","description":{"content":"_ButCoder Inc._ is a startup company whose main business is the development and operation of the programming competition site \"_ButCoder_\". There are $N$ members of the company including the president","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"cf17_exhibition_a"},"statements":[{"statement_type":"Markdown","content":"_ButCoder Inc._ is a startup company whose main business is the development and operation of the programming competition site \"_ButCoder_\".\nThere are $N$ members of the company including the president, and each member except the president has exactly one direct boss. Each member has a unique ID number from $1$ to $N$, and the member with the ID $i$ is called Member $i$. The president is Member $1$, and the direct boss of Member $i$ $(2 ≤ i ≤ N)$ is Member $b_i$ $(1 ≤ b_i < i)$.\nAll the members in ButCoder have gathered in the great hall in the main office to take a group photo. The hall is very large, and all $N$ people can stand in one line. However, they have been unable to decide the order in which they stand. For some reason, all of them except the president want to avoid standing next to their direct bosses.\nHow many ways are there for them to stand in a line that satisfy their desires? Find the count modulo $10^9+7$.\n\n## Constraints\n\n*   $2 ≤ N ≤ 2000$\n*   $1 ≤ b_i < i$ $(2 ≤ i ≤ N)$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$b_2$\n$b_3$\n$:$\n$b_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"cf17_exhibition_a","tags":[],"sample_group":[["4\n1\n2\n3","2\n\nBelow, we will write $A → B$ to denote the fact that Member $A$ is the direct boss of Member $B$.\nIn this case, the hierarchy of the members is $1 → 2 → 3 → 4$. There are two ways for them to stand in a line that satisfy their desires:\n\n*   $2, 4, 1, 3$\n*   $3, 1, 4, 2$\n\nNote that the latter is the reverse of the former, but we count them individually."],["3\n1\n2","0\n\nThe hierarchy of the members is $1 → 2 → 3$. No matter what order they stand in, at least one of the desires of Member $2$ and $3$ is not satisfied, so the answer is $0$."],["5\n1\n1\n3\n3","8\n\nThe hierarchy of the members is shown below:\n![image](https://img.atcoder.jp/cf17-exhibition/88bc845e074e0a3fecd96e2db9f3b1a5.png)\nThere are eight ways for them to stand in a line that satisfy their desires:\n\n*   $1, 4, 5, 2, 3$\n*   $1, 5, 4, 2, 3$\n*   $3, 2, 4, 1, 5$\n*   $3, 2, 4, 5, 1$\n*   $3, 2, 5, 1, 4$\n*   $3, 2, 5, 4, 1$\n*   $4, 1, 5, 2, 3$\n*   $5, 1, 4, 2, 3$"],["15\n1\n2\n3\n1\n4\n2\n7\n1\n8\n2\n8\n1\n8\n2","97193524"]],"created_at":"2026-03-03 11:01:14"}}