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>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
typedef vector<ll> vec;
const int MAX_N=2000;
int N;
const ll MOD=1e9+7;
vector<int> G[MAX_N];
vec dp[MAX_N][3];
ll minv2;
ll mpw(ll n,ll m){
	ll ret=1;
	while(m){
		if(m&1){
			ret*=n;
			ret%=MOD;
		}
		n*=n;
		n%=MOD;
		m>>=1;
	}
	return ret;
}
void add(ll &a,ll b){
	a+=b;
	if(a>=MOD){
		a-=MOD;
	}
}
void dfs(int v,int p){
	REP(i,3){
		int a=0;
		if(i==0)a=1;
		dp[v][i].push_back(a);
	}
	for(auto e:G[v]){
		if(e!=p){
			dfs(e,v);
			int n=(int)dp[v][0].size(),m=(int)dp[e][0].size();
			vec tmp[3];
			REP(i,3){
				tmp[i].resize(n+m);
			}
			REP(i,n){
				REP(d1,3){
					REP(j,m){
						REP(d2,3){
							int c2,d3;
							c2=i+j+1;
							d3=d1;
							add(tmp[d3][c2],dp[v][d1][i]*dp[e][d2][j]%MOD);
							if(d1==2 || d2==2)continue;
							d3=d1+1;
							ll x;
							c2--;
							if(d1==0 && d2==0){
								x=2;
							}else if(d1==0 || d2==0){
								x=1;
							}else{
								x=minv2;
							}
							add(tmp[d3][c2],dp[v][d1][i]*dp[e][d2][j]%MOD*x%MOD);
						}
					}
				}
			}
			REP(i,3){
				dp[v][i]=tmp[i];
			}
		}
	}
}
			
int main(){
	minv2=mpw(2,MOD-2);
	cin>>N;
	REP(i,N-1){
		int b;
		cin>>b;
		b--;
		G[i+1].push_back(b);
		G[b].push_back(i+1);
	}
	dfs(0,-1);
	ll ans=0,x=1,sgn=1;
	REP(i,N-1)sgn*=-1;
	REP(i,N){
		x*=(i+1);
		x%=MOD;
		REP(j,3){
			add(ans,(sgn*(dp[0][j][i]*x)%MOD+MOD)%MOD);
		}
		sgn*=-1;
	}
	cout<<ans<<endl;
}