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>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 2005;
const int mod = 1e9 + 7;

int n, siz[MAXN], g[MAXN][3], f[MAXN][MAXN][3];
vector <int> adj[MAXN];

inline void DFS(int x)
{
	siz[x] = 1, f[x][1][0] = 1;
	for (auto y : adj[x])
	{
		DFS(y), mcpy(g, f[x]), mset(f[x], 0);
		for (int dx = 0; dx <= 2; dx ++)
			for (int dy = 0; dy <= 2; dy ++)
				for (int dz = 0; dz <= 1; dz ++)
					if (!dz || (dx < 2 && dy < 2))
						for (int i = 1; i <= siz[x]; i ++)
							for (int j = 1; j <= siz[y]; j ++)
							{
								int cur = 1;
								if (dz)
								{
									cur = mod - 1;
									if (!dx && !dy)
										cur = (cur << 1) % mod;
									if (dx && dy)
										cur = cur >> 1;
								}
								f[x][i + j - dz][dx + dz] = (1LL * g[i][dx] * f[y][j][dy] % mod * cur + f[x][i + j - dz][dx + dz]) % mod;
							}
		siz[x] += siz[y];
	}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 2; i <= n; i ++)
		adj[Read()].pb(i);
	DFS(1);
	int ret = 0;
	for (int i = 0, cur = 1; i <= n; i ++, cur = 1LL * cur * i % mod)
		for (int j = 0; j <= 2; j ++)
			ret = (1LL * f[1][i][j] * cur + ret) % mod;
	return printf("%d\n", ret), 0;
}