#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll infll = 1e18;

template<typename T>
istream &operator>>(istream &is, vector<T> &a) {
    for (auto &i : a) {
        is >> i;
    }
    return is;
}

const int mod = 998244353;

int norm(int x) {
    if (x < 0) {
        x += mod;
    }
    if (x >= mod) {
        x -= mod;
    }
    return x;
}

int mul(int a, int b) {
    return (a * 1ll * b) % mod;
}

int binpow(int a, int n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) {
        return mul(a, binpow(a, n - 1));
    } else {
        int half = binpow(a, n / 2);
        return mul(half, half);
    }
}

const int N = 1e6 + 5;

vector<int> fact, inv_fact;

int C(int n, int k) {
    if (k < 0 || n < k) {
        return 0;
    }
    if (fact.empty()) {
        fact.resize(N);
        inv_fact.resize(N);
        fact[0] = 1;
        inv_fact[0] = 1;
        for (int i = 1; i < N; ++i) {
            fact[i] = mul(fact[i - 1], i);
            inv_fact[i] = binpow(fact[i], mod - 2);
        }
    }
    return mul(fact[n], mul(inv_fact[k], inv_fact[n - k]));
}

vector<bool> mark;
vector<vector<int>> g;
vector<int> sz;
vector<vector<int>> dp;

void dfs(int v, int p = -1) {
    sz[v] = 1;
    for (auto u : g[v]) {
        if (u != p) {
            dfs(u, v);
            sz[v] += sz[u];
        }
    }
    if (!mark[v]) {
        dp[v].resize(2);
        dp[v][0] = 1;
        int cur = 1;
        for (auto u : g[v]) {
            if (u != p) {
                vector<int> dpp(cur + sz[u] + 1);
                for (int i = 0; i <= cur; ++i) {
                    for (int j = 0; j <= sz[u]; ++j) {
                        (dpp[i + j] += mul(dp[v][i], dp[u][j])) %= mod;
                    }
                }
                dp[v] = dpp;
                cur += sz[u];
            }
        }
        return;
    }
    vector<vector<int>> dpp(2, vector<int>(3));
    dpp[0][0] = 1;
    dpp[1][2] = 1;
    int cur = 1;
    for (auto u : g[v]) {
        if (u != p) {
            vector<vector<int>> dppp(cur + sz[u] + 1, vector<int>(3));
            for (int i = 0; i <= cur; ++i) {
                for (int j = 0; j <= sz[u]; ++j) {
                    for (int k = 0; j + k <= sz[u]; ++k) {
                        if (i + j + k <= cur + sz[u]) {
                            (dppp[i + j + k][0] += mul(dpp[i][0], mul(dp[u][j], C(sz[u] - j, k)))) %= mod;
                            (dppp[i + j + k][1] += mul(dpp[i][1], mul(dp[u][j], C(sz[u] - j, k)))) %= mod;
                            (dppp[i + j + k][2] += mul(dpp[i][2], mul(dp[u][j], C(sz[u] - j, k)))) %= mod;
                            if (k > 0) {
                                (dppp[i + j + k][1] += mul(dpp[i][0], mul(dp[u][j], C(sz[u] - j, k)))) %= mod;
                                (dppp[i + j + k][2] += mul(dpp[i][1], mul(dp[u][j], C(sz[u] - j, k)))) %= mod;
                            }
                        }
                    }
                }
            }
            dpp = dppp;
            cur += sz[u];
        }
    }
    dp[v].resize(dpp.size());
    for (int i = 0; i < (int)dpp.size(); ++i) {
        dp[v][i] = dpp[i][2];
    }
}

int32_t main() {
#ifdef LOCAL
    freopen("C:\\work\\input.txt", "r", stdin);
#else
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int n, k;
    cin >> n >> k;
    mark.resize(n);
    for (int i = 0; i < k; ++i) {
        int v;
        cin >> v;
        --v;
        mark[v] = 1;
    }
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        --p;
        g[p].push_back(i);
        g[i].push_back(p);
    }
    sz.resize(n);
    dp.resize(n);
    dfs(0);
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        (ans += dp[0][i]) %= mod;
    }
    cout << ans << "\n";
    return 0;
}
