Problem: 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, 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).

All 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.

How many ways are there for them to stand in a line that satisfy their desires? Find the count modulo 10^9+7.

Constraints

* 2 ≤ N ≤ 2000
* 1 ≤ b_i < i (2 ≤ i ≤ N)

Input

Input is given from Standard Input in the following format:


N
b_2
b_3
:
b_N


Output

Print the number of ways for the N members to stand in a line, such that no member except the president is next to his/her direct boss, modulo 10^9+7.

Examples

Input

4
1
2
3


Output

2


Input

3
1
2


Output

0


Input

5
1
1
3
3


Output

8


Input

15
1
2
3
1
4
2
7
1
8
2
8
1
8
2


Output

97193524

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define maxn 2010
#define mod 1000000007
using namespace std;
struct edge{
	int r,nxt;
}e[maxn<<1];
int head[maxn],esz,fac[maxn],dp[maxn][maxn][3],n;
void addedge(int u,int v){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;
}
int dfs(int u){
	dp[u][0][0]=1;
	int sz=1,s;
	for(int t=head[u],v;t;t=e[t].nxt){
		s=dfs(v=e[t].r);
		for(int i=sz-1;i>=0;--i)
			for(int j=s-1;j>=0;--j){
				int A=(1ll*dp[v][j][0]+dp[v][j][1]+dp[v][j][2])%mod;
				dp[u][i+j+1][1]=(dp[u][i+j+1][1]+1ll*dp[u][i][0]*(2ll*dp[v][j][0]+dp[v][j][1]))%mod;
				dp[u][i+j+1][2]=(dp[u][i+j+1][2]+1ll*dp[u][i][1]*(dp[v][j][0]+1ll*dp[v][j][1]*(mod+1)/2%mod))%mod;
				if(j==0){
					dp[u][i][0]=1ll*dp[u][i][0]*A%mod;
					dp[u][i][1]=1ll*dp[u][i][1]*A%mod;
					dp[u][i][2]=1ll*dp[u][i][2]*A%mod;
				} else {
					dp[u][i+j][0]=(dp[u][i+j][0]+1ll*dp[u][i][0]*A)%mod;
					dp[u][i+j][1]=(dp[u][i+j][1]+1ll*dp[u][i][1]*A)%mod;
					dp[u][i+j][2]=(dp[u][i+j][2]+1ll*dp[u][i][2]*A)%mod;
				}
			}
			
		sz+=s;
	}
	return sz;
}
int main(){
	scanf("%d",&n),fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=2,x;i<=n;++i) 
		scanf("%d",&x),addedge(x,i);
	dfs(1);
	int ans=0;
	for(int i=0;i<n;++i)
		ans=(ans+1ll*(i&1?-1:1)*fac[n-i]*(1ll*dp[1][i][0]+dp[1][i][1]+dp[1][i][2])%mod+mod)%mod;
	printf("%d",ans);
}