#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int long long
const int MOD = 998244353;
vector<bool> flag;
vector<int> sz;
vector<int> fact;
vector<int> reverse_fact;

int binpow(int a, int b) {
    if (b == 0) {
        return 1;
    }
    if (b == 1) {
        return a;
    }
    if (b % 2 == 0) {
        int res = binpow(a, b / 2);
        return res * res % MOD;
    } else {
        int res = binpow(a, b - 1);
        return res * a % MOD;
    }
}

int C(int n, int k) {
    return fact[n] * reverse_fact[k] % MOD * reverse_fact[n - k] % MOD;
}

void dfs_sz(int u, vector<vector<int>> &g) {
    sz[u] = 1;
    for (int v: g[u]) {
        dfs_sz(v, g);
        sz[u] += sz[v];
    }
}

vector<int> dfs(int u, vector<vector<int>> &g) {
    if (!flag[u]) {
        vector<int> dp(sz[u] + 1);
        dp[1] = 1;
        for (int v: g[u]) {
            vector<int> dp1 = dfs(v, g);
            vector<int> ndp(sz[u] + 1);
            for (int i = 0; i < (int) dp1.size(); i++) {
                for (int j = 0; j < sz[u] + 1 - i; j++) {
                    ndp[i + j] += (int) ((dp1[i] * 1ll * dp[j] * 1ll) % (ll) MOD);
                    if (ndp[i + i] >= MOD) {
                        ndp[i + j] -= MOD;
                    }
                }
            }
            swap(dp, ndp);
        }
        return dp;
    } else {
        vector<vector<int>> dp(3, vector<int>(sz[u] + 1));
        dp[0][1] = 1;
        dp[2][0] = 1;
        for (int v: g[u]) {
            vector<int> dp1 = dfs(v, g);
            vector<vector<int>> ndp(3, vector<int>(sz[u] + 1));
            {
                for (int i = 0; i < (int) dp1.size(); i++) {
                    for (int j = 0; j < sz[u] + 1 - i; j++) {
                        ndp[0][i + j] += dp1[i] * dp[0][j] % MOD;
                        if (ndp[0][i + i] >= MOD) {
                            ndp[0][i + j] -= MOD;
                        }
                    }
                }
            }
            {
                for (int i = 0; i < (int) dp1.size(); i++) {
                    for (int j = 0; j < sz[u] + 1 - i; j++) {
                        ndp[1][i + j] += dp1[i] * dp[1][j] % MOD;
                        if (ndp[1][i + i] >= MOD) {
                            ndp[1][i + j] -= MOD;
                        }
                        for (int cnt = 1; cnt <= i; cnt++) {
                            ndp[1][i + j - cnt] += dp1[i] * dp[0][j] % MOD * C(i, cnt) % MOD;
                            if (ndp[1][i + j - cnt] >= MOD) {
                                ndp[1][i + j - cnt] -= MOD;
                            }
                        }
                    }
                }
            }
            {
                for (int i = 0; i < (int) dp1.size(); i++) {
                    for (int j = 0; j < sz[u] + 1; j++) {
                        for (int cnt = 0; cnt <= i; cnt++) {
                            ndp[2][i + j - cnt] += dp1[i] * dp[2][j] % MOD * C(i, cnt) % MOD;
                            if (ndp[2][i + j - cnt] >= MOD) {
                                ndp[2][i + j - cnt] -= MOD;
                            }
                            if (cnt > 0) {
                                ndp[2][i + j - cnt] += dp1[i] * dp[1][j] % MOD * C(i, cnt) % MOD;
                                if (ndp[2][i + j - cnt] >= MOD) {
                                    ndp[2][i + j - cnt] -= MOD;
                                }
                            }
                        }
                    }
                }
            }
            swap(dp, ndp);
        }
        return dp[2];
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    fact.assign(n + 1, 0);
    reverse_fact.assign(n + 1, 0);
    fact[0] = 1;
    reverse_fact[0] = binpow(fact[0], MOD - 2);
    for (int i = 1; i <= n; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        reverse_fact[i] = binpow(fact[i], MOD - 2);
    }
    flag.assign(n, false);
    sz.assign(n, 0);
    for (int i = 0; i < k; i++) {
        int id;
        cin >> id;
        flag[id - 1] = true;
    }
    vector<vector<int>> g(n);
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        g[p - 1].push_back(i);
    }
    dfs_sz(0, g);
    vector<int> dp = dfs(0, g);
    int res = 0;
    for (int val: dp) {
        res += val;
        if (res >= MOD) {
            res -= MOD;
        }
    }
    cout << res;
    return 0;
}