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>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
const ll INF = LLONG_MAX / 2;
const int MOD = 1e9 + 7;

int N;
ll sz[2010], dp[2010][2010][2];
vector<int> G[2010];

void dfs_sz(int u) {
	sz[u] = 1;
	for (int v: G[u]) dfs_sz(v), sz[u] += sz[v];
}

void dfs(int u) {
	int n = 1;
	vector<vector<int> > a(n + 1, vector<int>(3));
	a[0][0] = 1;
	for (int v: G[u]) {
		dfs(v);
		vector<vector<int> > _a(n + sz[v] + 1, vector<int>(3));
		rep(x, n + 1) rep(y, 3) if (a[x][y])
			rep(dx, sz[v] + 1) rep(dy, 2) if (dp[v][dx][dy]) {
				int _x = x + dx, _y = y + dy;
				if (_x > n + sz[v]) continue;
				if (_y > 2) continue;
				_a[_x][_y] = (_a[_x][_y] + (ll)a[x][y] * dp[v][dx][dy]) % MOD;
			}
		a = _a;
		n += sz[v];
	}
	rep(x, n + 1) {
		dp[u][x][0] = (dp[u][x][0] + a[x][0]) % MOD;
		dp[u][x + 1][1] = (dp[u][x + 1][1] - a[x][0]) % MOD;
		dp[u][x][0] = (dp[u][x][0] + a[x][1] * 2) % MOD;
		dp[u][x + 1][1] = (dp[u][x + 1][1] - a[x][1]) % MOD;
		dp[u][x][0] = (dp[u][x][0] + a[x][2] * 2) % MOD;
	}
}

ll F[2010];

int main() {
	F[0] = 1;
	rep(x, 2001) F[x + 1] = F[x] * (x + 1) % MOD;
	cin >> N;
	for (int u = 1; u < N; u++) {
		int p; cin >> p, p--;
		G[p].pb(u);
	}
	dfs_sz(0), dfs(0);
	/*
	rep(u, N) {
		rep(x, N + 1) cout << u << ' ' << x << ' ' << dp[u][x][0] << endl;
	}
	rep(x, N + 1) cout << x << ' ' << dp[0][x][0] << endl;
	*/
	int ans = 0;
	rep(x, N + 1) {
		ans = (ans + (ll)dp[0][x][0] * F[N - x]) % MOD;
	}
	cout << (ans + MOD) % MOD << endl;
}