#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <experimental/random>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ordered_set = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
using str = string;
using ld = long double;
const ll INF = 1e18, MOD = 998244353;
#define int long long
const int N = 600;
int c[N][N];
int binp(int v,int x) {
    if (x == 0) {
        return 1;
    }
    auto w = binp(v, x / 2);
    if (x % 2) {
        return w * w % MOD * v % MOD;
    }
    return w * w % MOD;
}

void solve();

signed main() {
    c[0][0] = 1;
    for (int i = 1; i < N; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j > 0) {
                c[i][j] += c[i - 1][j - 1];
            }
            if (j != i) {
                c[i][j] += c[i - 1][j];
            }
            c[i][j] %= MOD;
        }
    }
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--) {
        solve();
        //cout << "\n";
    }
}

vector<vector<int> > g;
vector<bool> us;
int n;

vector<int> dfs(int v) {
    vector<int> ans(n + 1);
    vector<vector<int> > f;
    for (auto to: g[v]) {
        f.push_back(dfs(to));
    }
    if (us[v]) {
        ans[0] = 1;
        for (int i = 0; i < f.size(); ++i) {
            vector<int> ans1(n + 1);
            for (int j = 0; j <= n; ++j) {
                int sum = f[i][j], sum1 = 0;
                for (int k = j + 1; k <= n; ++k) {
                    sum1 += f[i][k] * c[k][j];
                    sum1 %= MOD;
                }
                for (int k = n - j; k >= 0; --k) {
                    ans1[k + j] += ans[k] * sum1;
                    ans1[k + j] %= MOD;
                    ans1[k + j] += ans[k] * sum;
                    ans1[k + j] %= MOD;
                }
            }
            swap(ans, ans1);
        }
        vector ans2(3, vector<int>(n + 1));
        ans2[0][1] = 1;
        for (int i = 0; i < f.size(); ++i) {
            vector ans3(3, vector<int>(n + 1));
            for (int j = 0; j <= n; ++j) {
                int sum = f[i][j], sum1 = 0;
                for (int k = j + 1; k <= n; ++k) {
                    sum1 += f[i][k] * c[k][j];
                    sum1 %= MOD;
                }
                for (int i = 2; i >= 0; --i) {
                    for (int k = n - j; k >= 0; --k) {
                        ans3[min(i + 1, 2ll)][k + j] += ans2[i][k] * sum1;
                        ans3[min(i + 1, 2ll)][k + j] %= MOD;
                        ans3[i][k + j] += ans2[i][k] * sum;
                        ans3[i][k + j] %= MOD;
                    }
                }
            }
            swap(ans2, ans3);
        }
        for (int i = 0; i <= n; ++i) {
            ans[i] += ans2[2][i];
            ans[i] %= MOD;
        }
        return ans;
    } else {
        ans[1] = 1;
        for (int i = 0; i < f.size(); ++i) {
            vector<int> ans1(n + 1);
            for (int j = 0; j <= n; ++j) {
                for (int k = 0; k <= n; ++k) {
                    if (j + k <= n) {
                        ans1[j + k] += ans[j] * f[i][k];
                        ans1[j + k] %= MOD;
                    }
                }
            }
            swap(ans, ans1);
        }
        return ans;
    }
}

vector<int> cnt;

void dfs1(int v,int o) {
    if (o == -1) {
        for (auto to: g[v]) {
            cnt.push_back(0);
            dfs1(to, (int) cnt.size() - 1);
        }
    } else {
        cnt[o]++;
        for (auto to: g[v]) {
            dfs1(to, o);
        }
    }
}

void solve() {
    int k;
    cin >> n >> k;
    us.resize(n);
    for (int i = 0; i < k; ++i) {
        int x;
        cin >> x;
        us[x - 1] = true;
    }
    g.resize(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        g[p - 1].push_back(i);
    }
    if (k != 1) {
        auto t = dfs(0);
        int e = 0;
        for (int i = 0; i <= n; ++i) {
            e += t[i];
            e %= MOD;
        }
        cout << e;
    } else {
        int st = 0;
        for (int i = 0; i < n; ++i) {
            if (us[i]) {
                st = i;
                break;
            }
        }
        dfs1(st, -1);
        int ans = 1;
        for (int i = 0; i < cnt.size(); ++i) {
            ans *= binp(2, cnt[i]);
            ans %= MOD;
        }
        vector<int> dp(3);
        dp[0] = 1;
        for (int i = 0; i < cnt.size(); ++i) {
            int w = binp(2, cnt[i]) - 1, w1 = 1;
            vector<int> dp1(3);
            for (int i = 2; i >= 0; --i) {
                dp1[min(2ll, i + 1)] += dp[i] * w;
                dp1[min(2ll, i + 1)] %= MOD;
                dp1[i] += dp[i] * w1;
                dp1[i] %= MOD;
            }
            swap(dp, dp1);
        }
        cout << (ans + dp[2]) % MOD;
    }
}
