#pragma GCC optimize("O3,unroll-loops")
#include <vector>
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using dbl = long double;

constexpr ll P = 998244353;

unordered_map<ll, ll> mp;

ll pw(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2) return pw(a, b - 1) * a % P;
    ll x = pw(a, b / 2);
    return x * x % P;
}

inline ll dvd(ll a, ll b) {
    if (mp.count(b)) {
        return a * mp[b] % P;
    }
    mp[b] = pw(b, P - 2);
    return a * mp[b] % P;
}

vector<vector<pair<int, int>>> g;
vector<vector<pair<int, int>>> chg;
vector<int> s;
vector<vector<ll>> dp;
vector<int> prb;
int n = 0;

void dfs_dp(int u) {
    for (auto& [i, _] : g[u]) {
        dfs_dp(i);
    }
    if (prb[u] == 0) {
        for (int i = 0; i <= n; i++) {
            for (auto [j, _] : g[u]) {
                dp[u][i] *= dp[j][i];
                dp[u][i] %= P;
            }
            dp[u][i] *= pw(i + 1, s[u]);
            dp[u][i] %= P;
        }
    } else {
        vector<ll> mlt(n + 1, 1);
        for (int i = 0; i <= n; i++) {
            for (auto [j, _] : g[u]) {
                mlt[i] *= dp[j][i];
                mlt[i] %= P;
            }
            mlt[i] *= pw(i + 1, s[u]);
            mlt[i] %= P;
        }

        for (int i = 1; i <= n; i++) dp[u][i - 1] = mlt[i];
        for (int i = 1; i <= n; i++) {
            ll S = g[u].size();
            for (auto [j, dln] : g[u]) {
                ll x = dp[j][i];
                x *= pw(i + 1, dln);
                x %= P;
                ll y = dp[j][i - 1];
                y *= pw(i, dln);
                y %= P;
                dp[u][i - 1] = ((dp[u][i - 1] - dvd(mlt[i - 1], y) * x % P) + P) % P;
            }
            for (auto [sz, j] : chg[u]) {
                S += j;
                ll x = pw(i + 1, sz);
                ll y = pw(i, sz);
                dp[u][i - 1] = (dp[u][i - 1] - j * (dvd(mlt[i - 1], y) % P * x % P) + P) % P;
            }
            dp[u][i - 1] = (dp[u][i - 1] + mlt[i - 1] * (S - 1) % P) % P;
        }
    }
}

vector<int> tsk;
vector<vector<int>> bg;

pair<int, int> dfs(int u, int d) {
    int sz = 1;
    int cnt = 0;
    vector<pair<int, int>> xs;
    unordered_map<int, int> lns;
    for (auto& i : bg[u]) {
        auto [x, ln] = dfs(i, d + 1);
        sz += ln;
        if (x != -1) xs.push_back({x, ln});
        else lns[ln]++;
    }
    if (tsk[u] == 0) {
        if (xs.size() == 0) {
            return {-1, sz};
        }
        if (xs.size() == 1) {
            return {xs[0].first, sz};
        }
    }
    // use lns also if xs.size()
    int v = n++;
    g.push_back({});
    chg.push_back({});
    for (auto [i, ln] : xs) {
        g[v].push_back({i, ln});
    }
    s.push_back(sz);
    prb.push_back(tsk[u]);
    for (auto [i, j] : lns) {
        chg[v].push_back({i, j});
    }
    return {v, 0};
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int m, k;
    cin >> m >> k;
    vector<int> x(k);
    for (auto& i : x) cin >> i;
    for (auto& i : x) i--;
    vector<int> p(m);
    tsk.resize(m);
    bg.resize(m);
    for (auto i : x) tsk[i] = 1;
    for (int i = 1; i < m; i++) {
        cin >> p[i];
        p[i]--;
        bg[p[i]].push_back(i);
    }
    g.reserve(2000);
    chg.reserve(2000);
    s.reserve(2000);
    prb.reserve(2000);
    int rt = dfs(0, 0).first;
    dp.assign(n, vector<ll>(n + 1, 1));
    dfs_dp(rt);
    cout << dp[rt][0] << endl;
}