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 <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
vector<int> G[2000];
int B[2000];
int fact[2001];
vector<int> dp[2000][2];
vector<int> dp2[2][3];

vector<int> merge(vector<int> &a, vector<int> &b) {
  vector<int> o(a.size()+b.size()-1, 0);
  rep(i, a.size()) {
    rep(j, b.size()) {
      o[i+j] = (o[i+j] + 1LL*a[i]*b[j])%MOD;
    }
  }
  return o;
}
void add(vector<int> &to, vector<int> src) {
  if (to.size() < src.size()) to.resize(src.size(), 0);
  rep(i, src.size()) to[i] = (to[i]+src[i]) % MOD;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  fact[0] = 1;
  for (int i=1; i<=2000; i++) fact[i] = (1LL*i*fact[i-1])%MOD;

  cin >> N;
  for (int i=1; i<N; i++) {
    int p;
    cin >> p;
    p--;
    G[p].pb(i);
  }
  for (int x=N-1; x>=0; x--) {
    dp2[0][0] = {1};
    dp2[0][1] = {0};
    dp2[0][2] = {0};
    for (int t : G[x]) {
      rep(k, 3) dp2[1][k].clear();
      rep(k, 3) add(dp2[1][k], merge(dp2[0][k], dp[t][0]));
      rep(k, 2) add(dp2[1][k+1], merge(dp2[0][k], dp[t][1]));
      swap(dp2[0], dp2[1]);
    }
    add(dp[x][1], dp2[0][0]);
    add(dp[x][1], dp2[0][1]);
    dp[x][1].insert(dp[x][1].begin(), 0); // s++

    add(dp[x][0], dp2[0][0]);
    for (int &x : dp2[0][1]) x = (2LL*x) % MOD;
    for (int &x : dp2[0][2]) x = (2LL*x) % MOD;
    add(dp[x][0], dp2[0][1]);
    add(dp[x][0], dp2[0][2]);
  }
  int sum = 0;
  for (int s=0; s<dp[0][0].size(); s++) {
    int e = dp[0][0][s];
    if (s%2) e = (MOD-e) % MOD;
    sum = (sum + 1LL*e*fact[N-s])%MOD;
  }
  cout << sum << "\n";
  return 0;
}