#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
vector<vector<ll>> g;
vector<ll> dp, cnt;
ll bp(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

void dfs(int v) {
    cnt[v] = 1;
    for (int u : g[v]) {
        if (u > v) {
            dfs(u);
            dp[v] = (dp[v] * bp(2, cnt[u])) % mod;
            cnt[v] += cnt[u];
        }
    }
    if (dp[v] > 1) {
        dp[v]++;
    }
    dp[v] %= mod;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(k), b(n + 1);
    for (int i = 0; i < k; i++) {
        cin >> a[i];
    }
    g.resize(n + 1);
    cnt.resize(n + 1);
    for (int i = 2; i <= n; i++) {
        cin >> b[i];
        g[b[i]].push_back(i);
        g[i].push_back(b[i]);
    }
    dp.resize(n + 1, 1);
    dfs(a[0]);
    cout << dp[a[0]];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
