#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MOD = 998244353;

int n, k;
vector<int> x, f, sz;
vector<vector<int>> g, dp, e;

int binpow(int x, int st = MOD - 2) {
    int res = 1;
    while (st) {
        if (st&1) {
            st--;
            res = res * x % MOD;
        }
        st >>= 1;
        x = x * x % MOD;
    }
    return res;
}

int cnk(int n, int k) {
    return f[n] * binpow(f[k] * f[n - k] % MOD) % MOD;
}

vector<int> mrg(vector<int> a, vector<int> b) {
    vector<int> res(n + 1);
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j + i <= n; j++) {
            res[i + j] += a[i] * b[j] % MOD;
            if (res[i + j] >= MOD) res[i + j] -= MOD;
        }
    }
    return res;
}


void dfs(int v) {
    if (x[v]) {
        vector<vector<int>> now(3, vector<int>(n + 1));
        now[0][0] = 1;
        for (auto u : g[v]) {
            dfs(u);
            sz[v] += sz[u];
            vector<vector<int>> now2(3, vector<int>(n + 1));
            for (int j = 0; j <= sz[u]; j++) {
                for (int d = 0; j + d <= sz[u]; d++) {
                    for (int t = 0; t <= 2; t++) {
                        for (int j2 = 0; j2 + j + d < sz[v]; j2++) {
                            int t2 = min(2ll, t + (d != 0));
                            now2[t2][j2 + j + d] += ((dp[u][j] * e[sz[u] - j][d]) % MOD) * now[t][j2] % MOD;
                            if (now2[t2][j2 + j + d] >= MOD) now2[t2][j2 + j + d] -= MOD;
                        }
                    }
                }
            }
            now = now2;
        }
        for (int j = sz[v]; j >= 1; j--) {
            now[2][j] += now[0][j - 1] + now[1][j - 1] + now[2][j - 1];
            now[2][j] %= MOD;
        }
        dp[v] = now[2];
    }
    else {
        dp[v][0] = 1;
        for (auto u : g[v]) {
            dfs(u);
            sz[v] += sz[u];
            dp[v] = mrg(dp[v], dp[u]);
        }
    }
}

void solve() {
    cin >> n >> k;
    f.assign(n + 1, 1);
    sz.assign(n + 1, 1);
    for (int i = 2; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    x.assign(n + 1, 0);
    g.assign(n + 1, {});
    dp.assign(n + 1, vector<int>(n + 1));
    for (int i = 1; i <= k; i++) {
        int v;
        cin >> v;
        x[v]++;
    }
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        g[p].push_back(i);
    }
    e.assign(n + 1, vector<int>(n + 1));
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            e[i][j] = cnk(i, j);
        }
    }
    dfs(1);
    int ans = 0;
    for (int j = 1; j <= n; j++) {
        ans += dp[1][j];
        if (ans >= MOD) ans -= MOD;
    }
    cout << ans;
}

int32_t main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    solve();
}
