#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()

const ll mod = 998244353, mod2 = 1e9 + 7, P = 1e5 + 3;

ll sum(ll x, ll y) {
    return (x+y) % mod;
}

ll mul(ll x, ll y) {
    return (x*y)%mod;
}

ll diff(ll x, ll y) {
    return (x - y <0  ? x- y + mod : x - y);
}

ll bp(ll x, ll y) {
    ll ans = 1;
    while (y) {
        if (y&1) ans = mul(ans, x);
        x = mul(x, x);
        y>>=1;
    }
    return ans;
}

const int maxn = 510;
int fact[maxn], rfact[maxn];

int C[maxn][maxn];

void solve() {
    int n, k; cin >> n >> k;
    vector<int> tak(n);
    for (int j = 0; j < k; j++) {
        int v; cin >> v; v--; tak[v] = 1;
    }
    vector<vector<int>> g(n);
    for (int i = 1; i < n;i++) {
        int p; cin >> p; p--;
        g[p].pb(i);
    }

    vector<vector<int>> dp(n, vector<int>(n + 1));
    vector<int> sub(n, 1);
    for (int v = n - 1; v >= 0; v--) {
        for (int u : g[v]) sub[v] += sub[u];
        vector<vector<int>> dpc(3, vector<int>(sub[v] + 1));
        dpc[0][0] = 1;
        for (int u : g[v]) {
            auto dp2 = dpc;
            dp2.assign(3, vector<int>(sub[v] + 1, 0));
            for(int cnt = 0; cnt <= sub[u]; cnt++) {
                for (int w = 0; w <= 2; w++) {
                    for (int w2 = sub[v] - cnt; w2 >= 0;w2--) dp2[w][w2 + cnt] = sum(dp2[w][w2 + cnt], mul(dpc[w][w2], dp[u][cnt]));
                }
                if (tak[v]) {
                    for(int tk = 1;tk<=cnt; tk++) {
                        for (int w=2; w >= 0; w--) {
                            int dop = cnt - tk;
                            for (int w2 = sub[v] - dop; w2 >= 0; w2--) dp2[min(2, w+1)][w2 +dop] = sum(dp2[min(2, w + 1)][w2 + dop], 
                            mul(dpc[w][w2], mul(dp[u][cnt], C[cnt][tk])));
                        }
                    }
                }
            }
            swap(dpc, dp2);
            // for (int br = 0; br < sub[v]; br++) {
            //     for (int son = 0; son <= 2; son++) {
            //         if (v == 0) cout << br << ' ' << son << ' ' << dpc[son][br]<<endl;
            //         // if (!tak[v] || son == 2) {
            //         //     dp[v][br + 1] = sum(dp[v][br + 1], dpc[son][br]);
            //         // }
            //         // if (tak[v]) dp[v][br] = sum(dp[v][br], dpc[son][br]);
            //     }
            // }
            // cout << "----\n";
        }
        for (int br = 0; br < sub[v]; br++) {
            for (int son = 0; son <= 2; son++) {
                // if (v == 0) cout << br << ' ' << son << ' ' << dpc[son][br]<<endl;
                if (!tak[v] || son == 2) {
                    dp[v][br + 1] = sum(dp[v][br + 1], dpc[son][br]);
                }
                if (tak[v]) dp[v][br] = sum(dp[v][br], dpc[son][br]);
            }
        }
        // for (int cnt =0 ; cnt <= sub[v]; cnt++) cout << dp[v][cnt] << ' ';
        // cout<< endl;
    }
    ll ans = 0;
    for (int c=0;c<=n;c++) ans = sum(ans, dp[0][c]);
    cout << ans << '\n';
}

signed main() {
    int t = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        // cin >> t;
    #else 
        cin.tie(0)->sync_with_stdio(false);
    #endif 

    for (int n=0;n<maxn; n++) C[n][0] = 1;
    for (int k = 1; k < maxn; k++) for (int n = k; n < maxn; n++) C[n][k] = sum(C[n - 1][k], C[n - 1][k - 1]);

    fact[0] = 1;
    for (int j = 1; j < maxn; j++) fact[j] = mul(fact[j - 1], j);
    rfact[maxn - 1] = bp(fact[maxn - 1], mod - 2);
    for (int j = maxn - 2; j >=0 ; j--) rfact[j] = mul(rfact[j + 1], j + 1);

    while (t--) solve();

    return 0;
}