#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char zf = 1;
  char ch = getchar();
  while (ch != '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') zf = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * zf;
}
void write(long long y) {
  if (y < 0) putchar('-'), y = -y;
  if (y > 9) write(y / 10);
  putchar(y % 10 + 48);
}
void writeln(const long long y) {
  write(y);
  putchar('\n');
}
int i, j, k, m, n, x, y, z, cnt;
long long f[3030][3030], qz[3030][3030];
int d[3030], fa[3030];
int q[3030];
int ksm(long long x, int y) {
  if (!y) return 1;
  int ew = 1;
  while (y > 1) {
    if (y & 1) y--, ew = x * ew % 1000000007;
    y >>= 1, x = x * x % 1000000007;
  }
  return x * ew % 1000000007;
}
int main() {
  n = read();
  m = read();
  for (register int i = 2; i <= n; i++) {
    x = read();
    d[x]++;
    fa[i] = x;
  }
  int h = 0, t = 0;
  for (register int i = 1; i <= n; i++)
    if (!d[i]) {
      q[++t] = i;
      for (register int j = 1; j <= n; j++) f[i][j] = 1;
    }
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= n; j++) f[i][j] = 1;
  while (h < t) {
    x = q[++h];
    for (register int j = 1; j <= n; j++)
      qz[x][j] = (qz[x][j - 1] + f[x][j]) % 1000000007,
      (f[fa[x]][j] *= qz[x][j]) %= 1000000007;
    if (x == 1) break;
    if (!--d[fa[x]]) q[++t] = fa[x];
  }
  qz[1][0] = 0;
  long long ans = 0, s1, s2;
  for (register int i = 0; i <= n; i++) {
    s1 = 1;
    s2 = 1;
    for (register int j = 0; j <= n; j++)
      if (i != j) {
        s1 = s1 * (m - j) % 1000000007;
        s2 = s2 * (i - j) % 1000000007;
      }
    (ans += qz[1][i] * s1 % 1000000007 * ksm(s2, 1000000007 - 2)) %= 1000000007;
  }
  cout << ans;
  return 0;
}
