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>
using namespace std;typedef long long ll;
#define r(i,n) for(int i=0;i<n;i++)
const ll MN=2005;ll md=1e9+7;ll n,sz[MN],p[MN];vector<ll>g[MN];ll d[MN][MN][2];ll f[MN];ll a[MN][3],x[MN][3];
int main(){f[0]=1;for(ll i=1;i<MN;i++)f[i]=f[i-1]*i%md;cin>>n;for(ll i=2;i<=n;i++){cin>>p[i];g[p[i]].push_back(i);}for(ll i=n;i;i--){memset(a,0,sizeof(a));a[0][0]=1;for(auto &j:g[i]){memset(x,0,sizeof(x)); r(k,sz[j]+1)r(l,sz[i]+1)r(m,3){x[k+l][m]+=d[j][k][0]*a[l][m]%md;if(m<2) x[k+l+1][m+1]+=d[j][k][1]*a[l][m]%md;}sz[i]+=sz[j];r(j,sz[i]+1)r(k,3){a[j][k]=x[j][k]%md;}}r(j,sz[i]+1){d[i][j][0]=a[j][0]+a[j][1]*2+a[j][2]*2;d[i][j][1]=a[j][0]+a[j][1];d[i][j][0]%=md;d[i][j][1]%=md;}sz[i]++;}ll rt=0;r(i,n+1){ll cr=d[1][i][0]*f[n-i]%md;if(i & 1) cr=md-cr;rt+=cr;}cout<<rt%md<<endl;}