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;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define P 1000000007
#define N 2010
int n;
int a[N];
vector<int> A[N];
int f[N][N][3];
int g[N][3];
int s[N];

void ff(int x) {
	s[x] ++;
	f[x][0][0] = 1;
	for (vector<int>::iterator i = A[x].begin(); i != A[x].end(); i ++) {
		ff(*i);
		for (int j = 0; j < s[x]; j ++)
			for (int jj = 0; jj < 3; jj ++) {
				g[j][jj] = f[x][j][jj];
				f[x][j][jj] = 0;
			}
		
		for (int j = 0; j < s[x]; j ++)
			for (int jj = 0; jj < 3; jj ++)
				for (int k = 0; k < s[*i]; k ++)
					for (int kk = 0; kk < 3; kk ++) {
						// no delete
						int s = (ll)g[j][jj]*f[*i][k][kk]%P;
						int pp = jj;
						if (kk == 1) s = s*2%P;
						(f[x][j+k][pp] += s) %= P;
						
						// delete
						if (jj == 2 || kk == 2) continue;
						s = (ll)g[j][jj]*f[*i][k][kk]%P;
						if (jj && kk) {s = s*2%P; pp = 2;}
						if (jj && !kk) {s = s*2%P; pp = 2;}
						if (!jj && kk) {pp = 1;}
						if (!jj && !kk) {pp = 1;}
						(f[x][j+k+1][pp] += s) %= P;
					}
		s[x] += s[*i];
	}
}

int F[N];

int main() {
	F[0] = 1;
	for (int i = 1; i < N; i ++) F[i] = (ll)F[i-1]*i%P;
	cin >> n;
	a[0] = -1;
	for (int i = 1; i < n; i ++) {
		cin >> a[i];
		a[i] --;
		A[a[i]].pb(i);
	}
	memset(f, 0, sizeof f);
	ff(0);
	int S = 0;
	for (int i = 0; i < s[0]; i ++)
		for (int ii = 0; ii < 3; ii ++) {
			int s = f[0][i][ii];
			if (ii == 1) s = s*2%P;
			if (i%2) s = (P-s)%P;
			s = (ll)s*F[n-i]%P;
			S = (S+s)%P;
		}
	cout << S << endl;
	return 0;
}