#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
//#define int long long

const int mod = 998244353, N = 1e6 + 10;

int sum(int a, int b) {
    if (a + b >= mod) {
        return a + b - mod;
    }
    return a + b;
}

int raz(int a, int b) {
    if (a - b < 0) {
        return a - b + mod;
    }
    return a - b;
}

vector<int> g[N], dp[N];
int x[N], st[N], st2[N];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    st2[0] = 1;
    for (int i = 1; i < N; ++i) {
        st2[i] = sum(st2[i - 1], st2[i - 1]);
    }
    for (int i = 1; i <= k; ++i) {
        int y;
        cin >> y;
        x[y] = 1;
    }
    for (int i = 2; i <= n; ++i) {
        int j;
        cin >> j;
        g[j].pb(i);
    }
    int ans = 0;
    for (int i = n; i >= 1; --i) {
        int kol = 0;
        st[i] = 1;
        for (int j : g[i]) {
            st[i] += st[j];
            kol += sz(dp[j]) - 1;
        }
        kol++;
        if (x[i]) {
            if (st[i] == 1) {
                cout << 1;
                return 0;
            }
            ans = st2[st[i] - 1];
            ll pr = 1;
            for (int j : g[i]) {
                pr *= st2[st[j]];
                pr %= mod;
            }
            ans = sum(ans, pr);
            for (int j : g[i]) {
                ans = raz(ans, st2[st[j]]);
            }
            ans = sum(ans, st[i] - 2);
            cout << ans;
            kol += sz(g[i]) + 1;
            return 0;
        }
        vector<vector<int>> dp0(2, vector<int>(kol)), dp1, dp2;
        dp0[0][0] = 1;
        if (x[i]) {
            dp1.resize(2, vector<int>(kol));
            dp2.resize(2, vector<int>(kol));
            dp2[0][1] = 1;
        }
        for (int j : g[i]) {
            for (int tek = 0; tek < kol; ++tek) {
                dp0[1][tek] = 0;
                if (x[i]) {
                    dp1[1][tek] = 0;
                    dp2[1][tek] = 0;
                }
            }
            for (int f = 0; f < sz(dp[j]); ++f) {
                for (int tek = f; tek < kol; ++tek) {
                    dp0[1][tek] = sum(dp0[1][tek], (ll) dp[j][f] * dp0[0][tek - f] % mod);
                    if (x[i]) {
                        dp1[1][tek] = sum(dp1[1][tek], (ll) dp[j][f] * dp1[0][tek - f] % mod);
                        dp2[1][tek] = sum(dp2[1][tek], (ll) dp[j][f] * dp2[0][tek - f] % mod);
                        if (tek >= f + 1) {
                            dp1[1][tek] = sum(dp1[1][tek],
                                              (ll) dp[j][f] * dp0[0][tek - f - 1] % mod * (st[j] - f) % mod);
                            dp2[1][tek] = sum(dp2[1][tek],
                                              (ll) dp[j][f] * sum(dp1[0][tek - f - 1], dp2[0][tek - f - 1]) % mod * (
                                                  st[j] - f) % mod);
                        }
                    }
                }
            }
            swap(dp0[0], dp0[1]);
            if (x[i]) {
                swap(dp1[0], dp1[1]);
                swap(dp2[0], dp2[1]);
            }
        }
        if (x[i]) {
            for (int j = 0; j < kol; ++j) {
                dp0[0][j] = sum(dp0[0][j], dp2[0][j]);
            }
        }
        swap(dp[i], dp0[0]);
    }
    for (int i = 1; i < sz(dp[1]); ++i) {
        ans = sum(ans, dp[1][i]);
    }
    cout << ans;
    return 0;
}