#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define all(a) a.begin(), a.end()

void solve();

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
#ifdef LOCAL
    cin >> t;
#else
#endif
    while (t--) solve();
}

const ll N = 1e6 + 10, K = 1005;
const ll M = 998244353;
ll p[N], px[N], lst[N], x[K], whr[N], sz[N];
vector<ll> f[K];
ll mm[N], sliv[N], dp[K][K], cnt[N]{};

ll binpow(ll a, ll n) {
    ll ans = 1;
    for (; n > 0; n /= 2) {
        if (n & 1) ans = (ans * a) % M;
        a = (a * a) % M;
    }
    return ans;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    fill(whr, whr + n, -1);
    for (ll i = 0; i < k; i++) {
        cin >> x[i];
        x[i]--;
        whr[x[i]] = i;
    }
    for (ll j = 1; j < n; j++) {
        cin >> p[j];
        p[j]--;
    }
    px[0] = p[0] = lst[0] = -1;
    for (ll i = 1; i < n; i++) {
        if (whr[p[i]] >= 0) {
            px[i] = p[i];
            lst[i] = i;
        } else {
            px[i] = px[p[i]];
            lst[i] = lst[p[i]];
        }
    }
    fill(sz, sz + n, 0);
    fill(f, f + k, vector<ll>{});
    fill(mm, mm + n, -1);
    fill(sliv, sliv + n, -1);
    for (ll i = n - 1; i >= 0; i--) {
        sz[i]++;
        if (whr[i] >= 0) sz[i] = 0;
        if (px[i] >= 0) {
            if (p[i] == px[i])
                f[whr[px[i]]].push_back(i);
            sz[p[i]] += sz[i];
            if (whr[i] >= 0) {
                if (mm[lst[i]] == -1)
                    mm[lst[i]] = i;
                else
                    sliv[i] = mm[lst[i]];
            }
        }
    }
    ll ans = 1;
    vector<ll> fc, fu;
    for (ll v = n - 1; v >= 0; v--) {
        if (whr[v] == -1) continue;
        fc.clear();
        fu.clear();
        ll smz = 0;
        for (ll u: f[whr[v]]) {
            if (mm[u] == -1) {
                if (cnt[sz[u]]++ == 0)
                    fc.push_back(sz[u]);
                smz += sz[u];
            } else {
                fu.push_back(u);
            }
        }
        dp[whr[v]][K - 1] = 0;
        for (ll i = 0; i + 1 < K; i++) {
            ll pr = binpow(i + 2, smz + 1), ps = binpow(i + 1, smz + 1);
            for (ll u: fu) {
                pr = pr * dp[whr[mm[u]]][i + 1] % M * binpow(i + 2, sz[u]) % M;
                ps = ps * dp[whr[mm[u]]][i] % M * binpow(i + 1, sz[u]) % M;
            }
            ll vk = 1;
            for (ll u: fu) {
                ll r0 = dp[whr[mm[u]]][i] * binpow(i + 1, sz[u]) % M;
                ll r1 = dp[whr[mm[u]]][i + 1] * binpow(i + 2, sz[u]) % M;
                vk = (vk + (r1 - r0) * binpow(r0, M - 2)) % M;
            }
            for (ll c: fc) {
                ll r0 = binpow(i + 1, c);
                ll r1 = binpow(i + 2, c);
                vk = (vk + cnt[c] * (r1 - r0) % M * binpow(r0, M - 2)) % M;
            }
            dp[whr[v]][i] = (pr - vk * ps) % M;
            dp[whr[v]][i] = (dp[whr[v]][i] + M) % M;
        }
        for (ll u: f[whr[v]]) cnt[sz[u]] = 0;
        if (px[v] == -1)
            ans = ans * dp[whr[v]][0] % M;
        if (sliv[v] >= 0) {
            for (ll i = 0; i < K; i++)
                dp[whr[sliv[v]]][i] = dp[whr[sliv[v]]][i] * dp[whr[v]][i] % M;
        }
    }
    cout << (ans + M) % M << "\n";
}
