func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3010, Mo = 1000000007;   int tt, n, D;   int f[N][N], rev[N * 2], head[N], to[N], nxt[N];   inline int gi() {     int x = 0, o = 1;     char ch = getchar();     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   inline void dfs(int x) {     for (int i = 1; i <= n; i++) f[x][i] = 1;     for (int i = head[x]; i; i = nxt[i]) {       int y = to[i];       dfs(y);       for (int j = 1; j <= n; j++) f[x][j] = 1LL * f[x][j] * f[y][j] % Mo;     }     for (int i = 2; i <= n; i++) f[x][i] = (f[x][i - 1] + f[x][i]) % Mo;   }   inline int Pow(int x, int y) {     int ret = 1;     while (y) {       if (y & 1) ret = 1LL * ret * x % Mo;       x = 1LL * x * x % Mo, y >>= 1;     }     return ret;   }   int main() {     cin >> n >> D;     for (int i = 2, x; i <= n; i++)       to[++tt] = i, nxt[tt] = head[x = gi()], head[x] = tt;     dfs(1);     if (D <= n) return cout << f[1][D], 0;     int ans = 0;     for (int i = -n; i <= n; i++) rev[i + n] = Pow(i, Mo - 2);     for (int i = 0; i <= n; i++) {       int sum = f[1][i];       for (int j = 0; j <= n; j++)         if (i != j) sum = 1LL * sum * (D - j) % Mo * rev[i - j + n] % Mo;       (ans += sum) %= Mo;     }     cout << (ans + Mo) % Mo;     return 0;   }   