func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 3000 + 50;   const int maxm = 3000 + 50;   const int maxt = 3000000 + 100;   const int maxk = 10 + 3;   const long long unit = 1LL;   const int INF = 0x3f3f3f3f;   const long long Inf = 0x3f3f3f3f3f3f3f3fLL;   const double eps = 1e-3;   const double inf = 1e15;   const double pi = acos(-1.0);   const long long mod = 1000000007LL;   inline long long read() {     long long x = 0;     bool t = false;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) t = true, ch = getchar();     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch - 48, ch = getchar();     return t ? -x : x;   }   inline long long add(long long x, long long y) {     return x + y >= mod ? x + y - mod : x + y;   }   inline long long sub(long long x, long long y) {     return x < y ? x - y + mod : x - y;   }   inline long long mul(long long x, long long y) {     return x * y - x * y / mod * mod;   }   struct EasyMath {     inline long long Quick_Pow(long long a, long long b) {       long long sum = 1;       for (; b; b >>= 1, a = (long long)a * a % mod)         if (b & 1) sum = sum * a % mod;       return sum;     }     inline long long inv(long long x) { return Quick_Pow(x, mod - 2); }   } em;   long long n, d;   long long f[maxn][maxn], g[maxn], s[maxn][maxn], C[maxn][maxn];   long long inv[maxn], fac[maxn], ifac[maxn];   void GetInv(int n) {     inv[1] = fac[0] = fac[1] = ifac[0] = ifac[1] = 1;     for (register int i = (2); i <= (n); ++i) {       inv[i] = ((mod - mod / i)) * inv[mod % i] % mod;       fac[i] = fac[i - 1] * i % mod;       ifac[i] = ifac[i - 1] * inv[i] % mod;     }   }   struct Edge {     int to, next;   } edge[maxm];   int tot, head[maxn];   void init() {     tot = 1;     memset(head, 0, sizeof(head));   }   void AddEdge(int u, int v) {     edge[tot] = (Edge){v, head[u]};     head[u] = tot++;   }   void dfs(int u) {     for (int i = head[u]; i; i = edge[i].next) {       int v = edge[i].to;       dfs(v);       for (int j = 1; j <= n; ++j) (f[u][j] *= s[v][j]) %= mod;     }     for (int j = 1; j <= n; ++j) s[u][j] = (s[u][j - 1] + f[u][j]) % mod;   }   inline long long CC(long long n, long long m) {     long long ans = 1;     for (long long i = 0; i < m; ++i)       (ans *= ((n - i) * inv[i + 1]) % mod) %= mod;     return ans;   }   int main() {     init();     n = read(), d = read();     GetInv(n + 10);     C[0][0] = 1;     for (register int i = (1); i <= (n); ++i) {       C[i][0] = C[i][i] = 1;       for (register int j = (1); j <= (n); ++j) {         f[i][j] = 1;       }       for (register int j = (1); j <= (i - 1); ++j) {         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;       }     }     int x;     for (register int i = (2); i <= (n); ++i) {       x = read();       AddEdge(x, i);     }     dfs(1);     for (register int j = (1); j <= (n); ++j) {       g[j] = f[1][j];       for (register int i = (1); i <= (j - 1); ++i) {         g[j] = ((g[j] - C[j - 1][j - i] * g[i] % mod) % mod + mod) % mod;       }     }     long long ans = 0;     for (register int i = (1); i <= (min(n, d)); ++i) {       (ans += CC(d, i) * g[i] % mod) %= mod;     }     printf( %lld n , ans);     return 0;   }   