#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")
// #pragma GCC optimize("unroll-loops")

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 998244353;

vector<vector<ll>> g;
vector<bool> have;
vector<ll> sz;

ll power(ll x, ll y) {
    if (y == 0) return 1;
    if (y == 1) return x;
    ll ans = power(x, y / 2);
    ans = (ans * ans) % mod;
    if (y % 2 == 1) {
        ans = (ans * x) % mod;
    }
    return ans;
}

ll ans = 1;
ll n, k;

void dfs_k1(ll u) {
    for (auto v : g[u]) {
        dfs_k1(v);
        sz[u] += sz[v];
    }
    if (have[u]) {
        ans = power(2, n);
        for (auto v : g[u]) {
            ans = (ans - power(2, sz[v]));
            if (ans < 0) {
                ans += mod;
            }
        }
        ans = (ans + g[u].size() - 1) % mod;
    }
}

void solve() {
    cin >> n >> k;
    vector<ll> a(k);
    sz.resize(n, 1);
    have.assign(n, false);
    for (ll i = 0; i < k; i++) {
        cin >> a[i];
        have[a[i] - 1] = true;
    }
    g.resize(n);
    bool fl = true;
    for (ll i = 1; i < n; i++) {
        ll x;
        cin >> x;
        if (x != i) {
            fl = false;
        }
        g[x - 1].push_back(i);
    }
    if (fl) {
        ll cnt = k;
        for (ll i = n - 1; i >= 0; i--) {
            if (!have[i]) {
                ans = (ans * (cnt + 1)) % mod;
            } else {
                cnt--;
            }
        }
        cout << ans;
        return;
    }
    if (k == 1) {
        dfs_k1(0);
        cout << ans;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
