#include <bits/stdc++.h>
const int M = 50001;
const long long P = 1000000007ll;
using namespace std;
int n, m, k, a[M], f[M], ver[M], nex[M], head[M], cnt, d[3101][3100], D[3100],
    pr[M], inv[M], Inv[M], res;
void add(int x, int y) { ver[++cnt] = y, nex[cnt] = head[x], head[x] = cnt; }
long long qick(long long x, long long y) {
  long long z = 1;
  for (; y; y >>= 1, x = x * x % P)
    if (y & 1) z = z * x % P;
  return z % P;
}
int ins(int* a, int s) {
  long long res = 0, now = 1;
  for (int i = 1; i <= s; i++) {
    now = 1ll * pr[s] * Inv[i] % P * Inv[s - i] % P * qick(m - i, P - 2) % P *
          a[i] % P;
    if ((s - i) & 1)
      now *= -1;
    else
      now *= 1;
    res = (res + now + P) % P;
  }
  return res;
}
int dfs(int x) {
  for (int i = 1; i <= n; i++) d[x][i] = 1;
  int s = 1;
  for (int i = head[x]; i; i = nex[i]) {
    int t = dfs(ver[i]);
    for (int j = 1; j <= n; j++)
      d[x][j] = ((long long)d[x][j] * d[ver[i]][j]) % P;
    s += t;
  }
  for (int i = 1; i <= n; i++) d[x][i] = (d[x][i] + d[x][i - 1]) % P;
  return s;
}
int main() {
  scanf("%d%d", &n, &m);
  inv[0] = pr[0] = pr[1] = inv[1] = 1;
  for (int i = 2; i <= n; i++) inv[i] = (P - P / i) * 1ll * inv[P % i] % P;
  pr[0] = m;
  Inv[0] = 1;
  for (int i = 1; i <= n; i++) pr[i] = 1ll * pr[i - 1] * (m - i) % P;
  for (int i = 1; i <= n; i++) Inv[i] = 1ll * Inv[i - 1] * inv[i] % P;
  for (int i = 2; i <= n; i++) scanf("%d", &f[i]), add(f[i], i);
  dfs(1);
  if (m > n)
    res = ins(d[1], n);
  else
    res = d[1][m];
  printf("%d", res);
}
