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;

const int N = 2020;
const int mod = 1000000007;
using Arr = array<array<int, 5>, N>;

void add(int &x, int y) {
   x += y;
   if (x >= mod) x -= mod;
}

int mul(int x, int y) {
   return (long long) x * y % mod;
}

vector<int> g[N];
int sz[N];
Arr f[N];

Arr mrg(Arr x, Arr y, int sx, int sy) {
   Arr z = {};
   for (int ny = 1; ny <= sy; ++ny) {
      array<int, 2> cnt = {};
      for (int i = 0; i < 5; ++i) {
         add(cnt[i > 2], y[ny][i]);
      }
      for (int nx = 1; nx <= sx; ++nx) {
         for (int i = 0; i < 3; ++i) {
            add(z[nx + ny][i], mul(x[nx][i], cnt[0]));
            if (i < 2) {
               add(z[nx + ny - 1][i + 1], mul(x[nx][i], cnt[1]));
            }
         }
         for (int i = 3; i < 5; ++i) {
            add(z[nx + ny][i], mul(x[nx][i], cnt[0]));
            if (i < 4) {
               add(z[nx + ny - 1][i + 1], mul(x[nx][i], cnt[1]));
            }
         }
      }
   }
   return z;
}

void dfs(int u) {
   f[u][1][3] = mod - 1;
   f[u][1][0] = 1;
   sz[u] = 1;
   for (int v : g[u]) {
      dfs(v);
      f[u] = mrg(f[u], f[v], sz[u], sz[v]);
      sz[u] += sz[v];
   }
   for (int nu = 1; nu <= sz[u]; ++nu) {
      for (int i = 1; i < 3; ++i) {
         f[u][nu][i] = mul(f[u][nu][i], 2);
      }
   }
}

int main() {
   ios_base::sync_with_stdio(false);
   int n;
   cin >> n;
   for (int i = 2; i <= n; ++i) {
      int p;
      cin >> p;
      g[p].push_back(i);
   }
   dfs(1);
   int ans = 0;
   int fact = 1;
   for (int i = 1; i <= n; ++i) {
      fact = mul(fact, i);
      int ways = 0;
      for (int j = 0; j < 3; ++j) {
         add(ways, f[1][i][j]);
      }
      add(ans, mul(fact, ways));
   }
   cout << ans << "\n";
}