// Forza Ferrari!
#include <bits/stdc++.h>
using namespace std;

bool vsuprun() {
  static int iter = 0;
  static bool done = false;
  if (++iter == 100) {
    iter = 0;
    done = 1.0 * clock() / CLOCKS_PER_SEC >= 1.95;
  }
  return done;
}

constexpr int MOD = 998244353;

int binpow(int x, int y) {
  int result = 1;
  for (; y > 0; x = 1LL * x * x % MOD, y >>= 1) {
    if (y & 1) {
      result = 1LL * result * x % MOD;
    }
  }
  return result;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<vector<int>> graph(n);
  vector<bool> marked(n);
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    --x;
    marked[x] = true;
  }
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    graph[--p].push_back(i);
  }
  vector<int> fact(n + 1, 1), ifact(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    fact[i] = 1LL * fact[i - 1] * i % MOD;
  }
  ifact[n] = binpow(fact[n], MOD - 2);
  for (int i = n; i > 0; i--) {
    ifact[i - 1] = 1LL * ifact[i] * i % MOD;
  }
  auto Comb = [&](int x, int y) {
    return 1LL * fact[x] * ifact[y] % MOD * ifact[x - y] % MOD;
  };
  vector<vector<int>> dp(n);
  auto DFS = [&](auto&& self, int u) -> void {
    for (int v : graph[u]) {
      self(self, v);
    }
    if (marked[u]) {
      vector<array<int, 3>> help_dp(2, {0, 0, 0});
      help_dp[0][0] = 1; // don't take at all
      help_dp[1][0] = 1; // don't take, save for better times
      help_dp[0][2] = 1; // take now
      for (int v : graph[u]) {
        vector<array<int, 3>> new_dp(help_dp.size() + dp[v].size() - 1, {0, 0, 0});
        for (int i = 0; i < help_dp.size(); i++) {
          for (int ti = 0; ti < 3; ti++) {
            if (!help_dp[i][ti]) {
              continue;
            }
            for (int j = 0; j < dp[v].size(); j++) {
              for (int now = 0; now <= j; now++) {
                int new_left = min(2, ti + (now > 0));
                int subset = Comb(j, now);
                new_dp[i + j - now][new_left] = (new_dp[i + j - now][new_left] + 1LL * help_dp[i][ti] * dp[v][j] % MOD * subset) % MOD;
              }
            }
          }
        }
        help_dp = new_dp;
      }
      dp[u] = vector<int>(help_dp.size());
      // if we use vertex u
      for (int i = 0; i < help_dp.size(); i++) {
        dp[u][i] = help_dp[i][2];
      }
    } else {
      vector<int> help_dp(2);
      help_dp[0] = 1; // don't take at all
      help_dp[1] = 1; // save for better times, don't take
      for (int v : graph[u]) {
        vector<int> new_dp(help_dp.size() + dp[v].size() - 1);
        for (int i = 0; i < help_dp.size(); i++) {
          for (int j = 0; j < dp[v].size(); j++) {
            new_dp[i + j] = (new_dp[i + j] + 1LL * help_dp[i] * dp[v][j]) % MOD;
          }
        }
        help_dp = new_dp;
      }
      dp[u] = help_dp;
    }
  };
  DFS(DFS, 0);
  cout << dp[0][0] << "\n";
}
