Counting Orders

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

You are given a rooted tree on nn vertices numbered from 11 to nn. The root of the tree is vertex 11, and for each vertex ii (i2i \geq 2), its parent is vertex p_ip\_i

Consider a permutation q_iq\_i (1in1 \le i \le n). We will call this permutation proper if, for any vertex vv, all its descendants are located to the right of the position of vv in permutation qq.

You are asked to find the number of proper permutations q_iq\_i such that q_k=vq\_k = v, taken modulo 109+710^9 + 7.

입력

The first line of the input contains a single integer nn (1n50001 \leq n \leq 5000), the number of vertices in the tree.

The second line contains n1n-1 integers p_2,p_3,,p_np\_2, p\_3, \ldots, p\_n (1p_i<i1 \leq p\_i < i), the parents of all vertices in the tree except the root. In particular, when n=1n = 1, the second line is present but empty.

The last line contains two integers vv and kk (1v,kn1 \le v, k \le n).

출력

Output one integer: the remainder of the number of proper permutations q_iq\_i with q_k=vq\_k = v modulo 109+710^9 + 7.

힌트

The valid proper permutations for the sample case are:

1324561 3 2 4 5 6, 1324651 3 2 4 6 5, 1325461 3 2 5 4 6, 1325641 3 2 5 6 4, 1326451 3 2 6 4 5, 1326541 3 2 6 5 4, 1423561 4 2 3 5 6, 1423651 4 2 3 6 5, 1425361 4 2 5 3 6.