func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3e3 + 5, mod = 1e9 + 7;   struct p {     int x, y;   } c[N];   int n, D, num;   int h[N], w[N];   int f[N][N];   int read() {     int x(0);     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       ;     for (; isdigit(ch); x = x * 10 + ch - 48, ch = getchar())       ;     return x;   }   void add(int x, int y) { c[++num] = (p){h[x], y}, h[x] = num; }   void dfs(int x = 1) {     for (int i = 1; i <= n; ++i) f[x][i] = 1;     for (int i = h[x]; i; i = c[i].x) {       dfs(c[i].y);       for (int j = 1; j <= n; ++j) f[x][j] = 1ll * f[x][j] * f[c[i].y][j] % mod;     }     for (int i = 1; i <= n; ++i) {       f[x][i] += f[x][i - 1];       if (f[x][i] >= mod) f[x][i] -= mod;     }   }   int Pow(int a, int b) {     int ans = 1;     for (; b; b >>= 1, a = 1ll * a * a % mod)       if (b & 1) ans = 1ll * ans * a % mod;     return ans;   }   int L(int x) {     int ans = 1;     for (int i = 0; i <= n; ++i)       if (x != i)         ans = (1ll * ans * (D - i) % mod * (x - i < 0 ? -1 : 1) *                    w[x - i < 0 ? i - x : x - i] % mod +                mod) %               mod;     return ans;   }   void Solve() {     if (n >= D) return void(printf( %d , f[1][D]));     int ans = 0;     for (int i = 1; i <= n; ++i) w[i] = Pow(i, mod - 2);     for (int i = 0; i <= n; ++i) {       ans += 1ll * f[1][i] * L(i) % mod;       if (ans >= mod) ans -= mod;     }     printf( %d , ans);   }   int main() {     n = read(), D = read();     for (int i = 2; i <= n; ++i) add(read(), i);     return dfs(), Solve(), 0;   }   