#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
long long inv(long long a, long long b = md) {
  return a > 1 ? b - inv(b % a, a) * b / a : 1;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  vector<vector<int>> ch(n);
  for (int i = (1); i < (n); ++i) {
    int p;
    cin >> p;
    ch[p - 1].push_back(i);
  }
  vector<vector<long long>> ways(n, vector<long long>(n + 1));
  for (int i = (n); i-- > (0);) {
    for (int x = (1); x < (n + 1); ++x) {
      long long prod = 1;
      for (auto &j : ch[i]) prod = prod * ways[j][x] % md;
      ways[i][x] = (ways[i][x - 1] + prod) % md;
    }
  }
  vector<long long> poly(n + 2);
  poly[0] = 1;
  for (int x = (0); x < (n + 1); ++x) {
    for (int i = (n + 2); i-- > (1);)
      poly[i] = (poly[i - 1] - x * poly[i]) % md;
    poly[0] = (-x * poly[0]) % md;
  }
  vector<long long> ans(n + 1);
  for (int x = (0); x < (n + 1); ++x) {
    vector<long long> pol = poly;
    vector<long long> lag(n + 1);
    for (int i = (n + 1); i-- > (0);) {
      lag[i] = pol[i + 1];
      pol[i] = (pol[i] + x * pol[i + 1]) % md;
    }
    assert(pol[0] == 0);
    long long res = 0;
    for (int i = (n + 1); i-- > (0);) res = (res * x + lag[i]) % md;
    if (res < 0) res += md;
    long long c = ways[0][x] * inv(res) % md;
    for (int i = (0); i < (n + 1); ++i) ans[i] = (ans[i] + c * lag[i]) % md;
  }
  long long val = 0;
  for (int i = (n + 1); i-- > (0);) val = (val * d + ans[i]) % md;
  if (val < 0) val += md;
  cout << val << endl;
}
