#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

const int mod = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;

    vector<int> x(k), mk(n + 1, 0);
    for (int i = 0; i < k; i++) {
        cin >> x[i];
        mk[x[i]] = 1;
    }

    vector<int> p(n + 1, 0), h(n + 1, -1), to(n), nx(n);
    int e = 0;
    for (int i = 2; i <= n; i++) {
        cin >> p[i];
        to[e] = i;
        nx[e] = h[p[i]];
        h[p[i]] = e++;
    }

    vector<int> sz(n + 1, 1), cnt = mk;
    for (int i = n; i >= 2; i--) {
        sz[p[i]] += sz[i];
        cnt[p[i]] += cnt[i];
    }

    vector<int> c(n + 1, 0), g(n + 1, 1), ne(n + 1, 0);
    for (int i = 2; i <= n; i++) {
        if (cnt[i]) {
            c[p[i]]++;
            if (!ne[p[i]]) ne[p[i]] = i;
        }
        else {
            g[p[i]] += sz[i];
        }
    }

    vector<int> imp(n + 1, 0), id(n + 1, -1), o;
    o.reserve(2 * k + 5);
    for (int i = 1; i <= n; i++) {
        if (cnt[i] && (mk[i] || i == 1 || c[i] != 1)) {
            imp[i] = 1;
            id[i] = (int)o.size();
            o.push_back(i);
        }
    }

    int m = (int)o.size();

    vector<int> tp(m), dp(m, 0), pw0(m, 0), sm0(m, 0);
    vector<vector<int>> ch(m), raw(m);
    vector<vector<pair<int, int>>> sp(m);

    for (int i = 0; i < m; i++) {
        int v = o[i];
        tp[i] = mk[v];
        if (!tp[i]) pw0[i] = 1;
    }

    for (int i = 0; i < m; i++) {
        int v = o[i];
        for (int j = h[v]; j != -1; j = nx[j]) {
            int u = to[j];
            if (!cnt[u]) {
                if (tp[i]) raw[i].push_back(sz[u]);
                else pw0[i] += sz[u];
            }
            else {
                int y = u, w = 0;
                while (!imp[y]) {
                    w += g[y];
                    y = ne[y];
                }
                int z = id[y];
                ch[i].push_back(z);
                if (tp[i]) sp[i].push_back({ z, w });
                else pw0[i] += w;
            }
        }
    }

    vector<int> ord, st;
    ord.reserve(m);
    st.push_back(id[1]);
    while (!st.empty()) {
        int v = st.back();
        st.pop_back();
        ord.push_back(v);
        for (int u : ch[v]) {
            dp[u] = dp[v] + tp[v];
            st.push_back(u);
        }
    }

    vector<vector<pair<int, int>>> gp(m);
    for (int i = 0; i < m; i++) {
        if (!tp[i] || raw[i].empty()) continue;
        sort(raw[i].begin(), raw[i].end());
        for (int v : raw[i]) sm0[i] += v;
        int j = 0;
        while (j < (int)raw[i].size()) {
            int t = j;
            while (t < (int)raw[i].size() && raw[i][t] == raw[i][j]) t++;
            gp[i].push_back({ raw[i][j], t - j });
            j = t;
        }
    }

    int mx = k + 1;
    int B = 1024;
    int M = n / B + 2;

    vector<int> a((mx + 1) * B), b((mx + 1) * M);

    for (int i = 1; i <= mx; i++) {
        a[i * B] = 1;
        for (int j = 1; j < B; j++) a[i * B + j] = (long long)a[i * B + j - 1] * i % mod;

        int v = 1;
        for (int j = 0; j < B; j++) v = (long long)v * i % mod;

        b[i * M] = 1;
        for (int j = 1; j < M; j++) b[i * M + j] = (long long)b[i * M + j - 1] * v % mod;
    }

    auto pw = [&](int x, int y) -> int {
        return (long long)b[x * M + y / B] * a[x * B + y % B] % mod;
        };

    vector<vector<int>> f(m);

    for (int ii = m - 1; ii >= 0; ii--) {
        int v = ord[ii];
        int L = dp[v] + 1;
        f[v].assign(L + 1, 0);

        if (!tp[v]) {
            for (int q = 1; q <= L; q++) {
                long long res = pw(q, pw0[v]);
                for (int u : ch[v]) res = res * f[u][q] % mod;
                f[v][q] = (int)res;
            }
        }
        else {
            int t = (int)sp[v].size();
            vector<int> A(t), C(t), pr(t + 1), sf(t + 1);

            for (int q = 1; q <= L; q++) {
                for (int i = 0; i < t; i++) {
                    int u = sp[v][i].first;
                    int w = sp[v][i].second;
                    A[i] = (long long)pw(q, w) * f[u][q] % mod;
                    C[i] = (long long)pw(q + 1, w) * f[u][q + 1] % mod;
                }

                pr[0] = 1;
                for (int i = 0; i < t; i++) pr[i + 1] = (long long)pr[i] * A[i] % mod;

                sf[t] = 1;
                for (int i = t - 1; i >= 0; i--) sf[i] = (long long)sf[i + 1] * A[i] % mod;

                long long s0 = pr[t], sa = 1, s1 = 0;
                for (int i = 0; i < t; i++) {
                    sa = sa * C[i] % mod;
                    s1 += (long long)(C[i] - A[i] + mod) % mod * pr[i] % mod * sf[i + 1] % mod;
                    if (s1 >= mod) s1 %= mod;
                }

                long long p0 = pw(q, sm0[v]);
                long long pa = pw(q + 1, sm0[v]);
                long long p1 = 0;

                for (auto& it : gp[v]) {
                    int s = it.first;
                    int c2 = it.second;
                    long long z = pw(q + 1, s) - pw(q, s);
                    if (z < 0) z += mod;
                    z = z * pw(q, sm0[v] - s) % mod * c2 % mod;
                    p1 += z;
                    if (p1 >= mod) p1 %= mod;
                }

                long long z0 = s0 * p0 % mod;
                long long za = sa * pa % mod;
                long long z1 = (s1 * p0 + s0 * p1) % mod;

                long long d = za - z0 - z1;
                d %= mod;
                if (d < 0) d += mod;

                f[v][q] = (za + (long long)q * d) % mod;
            }
        }
    }

    cout << f[id[1]][1] << '\n';
    return 0;
}