#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ff first
#define ss second

using namespace std;

const int mod = 998244353;

int binpow(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return binpow((x * x) % mod, y / 2);
    return (x * binpow(x, y - 1)) % mod;
}

vector <vector <int>> g;
vector <int> sz;

void dfs(int v) {
    sz[v] = 1;
    for (auto u : g[v]) {
        dfs(u);
        sz[v] += sz[u];
    }
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector <int> a(k);
    for (int i = 0; i < k; ++i) {
        cin >> a[i];
    }
    bool f = true;
    g.assign(n + 1, {});
    sz.assign(n + 1, 0);
    for (int i = 2; i <= n; ++i) {
        int x;
        cin >> x;
        g[x].push_back(i);
        if (x != i - 1) f = false;
    }
    if (k == 1) {
        dfs(1);
        int v = a[0];
        int ans = binpow(2, sz[v]) - 1;
        for (auto u : g[v]) {
            ans -= binpow(2, sz[u]) - 1;
            if (ans < 0)
                ans += mod;
        }
        cout << ans;
        return;
    }
    if (f) {
        sort(all(a));
        int ans = 1;
        int ind = 0;
        for (int i = 1; i <= n; ++i) {
            if (ind < k && a[ind] == i) ++ind;
            else ans *= ind + 1;
            ans %= mod;
        }
        cout << ans;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int t = 1;
    while (t--) solve(), cout << '\n';
}
