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 <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
vector<int> ch[2020];

i64 modpow(i64 a, int p = MOD - 2)
{
	if (p == 0) return 1;
	i64 ret = modpow(a, p / 2);
	ret = ret * ret % MOD;

	if (p % 2 == 1) ret = ret * a % MOD;
	return ret;
}

i64 fact[2020], facti[2020];

vector<vector<i64>> join(vector<vector<i64>> &data, vector<i64> &ext0, vector<i64> &ext1)
{
	vector<vector<i64>> ret(3, vector<i64>(data[0].size() + ext0.size() - 1, 0LL));
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < data[0].size(); ++j) {
			for (int k = 0; k < ext0.size(); ++k) {
				ADD(ret[i][j + k], data[i][j] * ext0[k]);

				if (i == 0) ADD(ret[i + 1][j + k], data[i][j] * ext1[k]);
				else if (i == 1) ADD(ret[i + 1][j + k], data[i][j] * ext1[k]  % MOD * facti[2]);
			}
		}
	}
	return ret;
}

vector<vector<i64>> solve(int p)
{
	vector<vector<i64>> ret(3, vector<i64>());
	ret[0].push_back(1LL);
	ret[1].push_back(0LL);
	ret[2].push_back(0LL);
	for (int q : ch[p]) {
		auto ans = solve(q);

		// extend
		vector<i64> ext0(ans[0].size() + 1, 0LL), ext1(ans[0].size() + 1, 0LL);
		for (int i = 0; i < ans[0].size(); ++i) {
			ADD(ext0[i], ans[0][i]);
			ADD(ext0[i], ans[1][i]);
			ADD(ext0[i], ans[2][i]);
			ADD(ext1[i + 1], ans[0][i] * 2);
			ADD(ext1[i + 1], ans[1][i]);
			// ADD(ext1[i], ans[2][i]);
		}
		ret = join(ret, ext0, ext1);
	}
	/*
	printf("%d\n", p);
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < ret[0].size(); ++j) printf("%lld ", ret[i][j]);
		puts("");
	}
	puts("---");
	*/
	return ret;
}

int main()
{
	scanf("%d", &N);
	fact[0] = facti[0] = 1;
	for (int i = 1; i <= N; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
		facti[i] = modpow(fact[i]);
	}
	for (int i = 1; i < N; ++i) {
		int p;
		scanf("%d", &p);
		--p;
		ch[p].push_back(i);
	}

	auto ans = solve(0);

	i64 ret = 0;
	for (int i = 0; i < N; ++i) {
		i64 val = 0;
		ADD(val, ans[0][i]);
		ADD(val, ans[1][i]);
		ADD(val, ans[2][i]);

		if (i % 2 == 1) val = MOD - val % MOD;
		ADD(ret, val * fact[N - i]);
	}
	printf("%lld\n", ret);

	return 0;
}