{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eYou are given a rooted tree with \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e nodes. The nodes are numbered\n \u003cspan class\u003d\"tex2jax_process\"\u003e$1..n$\u003c/span\u003e. The root is node\n \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e, and \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e of the nodes are colored red, the\n rest are black.\u003c/p\u003e\n \u003cp\u003eYou would like to choose a subset of nodes such that there\n is no node in your subset which is an ancestor of any other\n node in your subset. For example, if A is the parent of B and B\n is the parent of C, then you could have at most one of A, B or\n C in your subset. In addition, you would like exactly\n \u003cspan class\u003d\"tex2jax_process\"\u003e$k$\u003c/span\u003e of your chosen nodes\n to be red.\u003c/p\u003e\n \u003cp\u003eIf exactly \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e of the\n nodes are red, then for all \u003cspan class\u003d\"tex2jax_process\"\u003e$k\u003d0..m$\u003c/span\u003e, figure out how many ways you\n can choose subsets with \u003cspan class\u003d\"tex2jax_process\"\u003e$k$\u003c/span\u003e red nodes, and no node is an\n ancestor of any other node.\u003c/p\u003e\n \u003ch2\u003eInput\u003c/h2\u003e\n \u003cp\u003eEach input will consist of a single test case. Note that\n your program may be run multiple times on different inputs.\n Each test case will begin with a line with two integers\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1 \\le n \\le 2 \\times 10^5$\u003c/span\u003e) and\n \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$0 \\le m \\le min(10^3,\\ n)$\u003c/span\u003e), where\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e is the number of nodes\n in the tree, and \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e is\n the number of nodes which are red. The nodes are numbered\n \u003cspan class\u003d\"tex2jax_process\"\u003e$1..n$\u003c/span\u003e.\u003c/p\u003e\n \u003cp\u003eEach of the next \u003cspan class\u003d\"tex2jax_process\"\u003e$n-1$\u003c/span\u003e\n lines will contain a single integer \u003cspan class\u003d\"tex2jax_process\"\u003e$p$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1\n \\le p \\le n$\u003c/span\u003e), which is the number of the parent of this\n node. The nodes are listed in order, starting with node\n \u003cspan class\u003d\"tex2jax_process\"\u003e$2$\u003c/span\u003e, then node\n \u003cspan class\u003d\"tex2jax_process\"\u003e$3$\u003c/span\u003e, and so on. Node\n \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e is skipped, since it\n is the root. It is guaranteed that the nodes form a single\n tree, with a single root at node \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e and no cycles.\u003c/p\u003e\n \u003cp\u003eEach of the next \u003cspan class\u003d\"tex2jax_process\"\u003e$m$\u003c/span\u003e\n lines will contain single integer \u003cspan class\u003d\"tex2jax_process\"\u003e$r$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1\n \\le r \\le n$\u003c/span\u003e). These are the numbers of the red nodes.\n No value of \u003cspan class\u003d\"tex2jax_process\"\u003e$r$\u003c/span\u003e will be\n repeated.\u003c/p\u003e\n \u003ch2\u003eOutput\u003c/h2\u003e\n \u003cp\u003eOutput \u003cspan class\u003d\"tex2jax_process\"\u003e$m+1$\u003c/span\u003e lines,\n corresponding to the number of subsets satisfying the given\n criteria with a number of red nodes equal to \u003cspan class\u003d\"tex2jax_process\"\u003e$k\u003d0..m$\u003c/span\u003e, in that order. Output this\n number modulo \u003cspan class\u003d\"tex2jax_process\"\u003e$10^9+7$\u003c/span\u003e.\u003c/p\u003e\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 1\n1\n1\n1\n3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\n4\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n \u003ch2\u003eSample 2\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4 4\n1\n1\n1\n1\n2\n3\n4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n4\n3\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n \u003ch2\u003eSample 3\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e14 4\n1\n2\n1\n2\n3\n4\n5\n5\n13\n8\n10\n4\n4\n8\n3\n12\n13\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e100\n169\n90\n16\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}