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 <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

const long long mod = 1000000007;
const long long inv2 = (mod + 1) / 2;
vector<int> G[2020];

vector<long long> mul(vector<long long> &a, vector<long long> &b)
{
	vector<long long> r(a.size()+b.size()-1);
	for (int i=0;i<a.size();i++) for (int j=0;j<b.size();j++){
		r[i+j] = (r[i+j] + a[i] * b[j]) % mod;
	}
	return move(r);
}

vector<long long> add(vector<long long> &a, vector<long long> &b, int sig = 1)
{
	vector<long long> r(max(a.size(),b.size()));
	for (int i=0;i<a.size();i++) r[i] = a[i];
	for (int i=0;i<b.size();i++) r[i] = (r[i] + b[i] * sig % mod + mod) % mod;
	return move(r);
}

vector<vector<long long> > go(int x)
{
	vector<vector<long long> > r(3,vector<long long>(2,0));
	r[0][1] = 1;

	for (auto &y : G[x]){
		auto q = go(y);
		auto s = q[0];
		s = add(s,q[1]);
		s = add(s,q[2]);

		vector<vector<long long> > nr(3);
		for (int k=0;k<3;k++) nr[k] = mul(r[k],s);
		long long coeff[2][2] = {2,1,1,inv2};
		for (int i=0;i<2;i++) for (int j=0;j<2;j++){
			auto t = mul(r[i],q[j]);
			t.erase(t.begin());
			nr[i+1] = add(nr[i+1],t,-coeff[i][j]);
		}
		r = move(nr);
	}

	return move(r);
}

int main()
{
	int N; scanf ("%d",&N);
	for (int i=2;i<=N;i++){
		int p; scanf ("%d",&p);
		G[p].push_back(i);
	}

	auto r = go(1);

	long long ans = 0, f = 1;
	for (int i=1;i<=N;i++){
		f = f * i % mod;
		ans = (ans + (r[0][i] + r[1][i] + r[2][i]) * f) % mod;
	}
	printf ("%lld\n",ans);

	return 0;
}