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>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inv2 = 5e8 + 4;

vector< int > g[100000];
vector< vector< int64 > > dp[100000];

void rec(int idx) {
  vector< vector< int64 > > sub(3, vector< int64 >(1));
  sub[0][0] = 1;
  for(auto &to : g[idx]) {
    rec(to);
    auto &ch = dp[to];
    vector< int64 > sub1(ch[0].size() + 1);
    for(int i = 0; i < ch[0].size(); i++) {
      (sub1[i + 1] += ch[0][i] * 2) %= mod;
      (sub1[i + 1] += ch[1][i]) %= mod;
    }
    vector< vector< int64 > > beet(3, vector< int64 >(sub[0].size() + ch[0].size()));
    for(int k = 0; k < 3; k++) {
      for(int i = 0; i < sub[k].size(); i++) {
        for(int j = 0; j <= ch[0].size(); j++) {
          if(j < ch[0].size()) {
            for(int l = 0; l < 3; l++) {
              (beet[k][i + j] += sub[k][i] * ch[l][j] % mod) %= mod;
            }
          }
          if(k == 0) (beet[1][i + j] += sub[k][i] * sub1[j]) %= mod;
          if(k == 1) (beet[2][i + j] += sub[k][i] * sub1[j] % mod * inv2) %= mod;
        }
      }
    }
    for(int k = 0; k < 3; k++) ch[k].clear();
    sub.swap(beet);
  }
  dp[idx].swap(sub);
}

int main() {
  int N;
  cin >> N;
  for(int i = 1; i < N; i++) {
    int p;
    cin >> p;
    g[--p].emplace_back(i);
  }

  int64 fact[2002];
  fact[0] = 1;
  for(int i = 1; i < 2002; i++) {
    (fact[i] = fact[i - 1] * i) %= mod;
  }

  rec(0);

  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    int64 add = 0;
    for(int j = 0; j < 3; j++) (add += dp[0][j][i]) %= mod;
    (add *= fact[N - i]) %= mod;
    if(i & 1) (ret += mod - add) %= mod;
    else (ret += add) %= mod;
  }

  cout << ret << endl;
}