#include <experimental/random>
#include <bits/stdc++.h>

using namespace std;
//experimental::randint(1, 10);
#define ll long long

ll MOD = 998244353;
ll INF = 1e18;
vector<vector<ll> > g;
vector<ll> up;
vector<ll> col;
ll step(ll v,ll ind) {
    if (ind == 0) {
        return 1;
    }
    if (ind % 2 == 0) {
        ll x = step(v, ind / 2);
        return (x * x) % MOD;
    }
    return (step(v, ind - 1) * v) % MOD;
}

void dfs(ll v) {
    col[v] = 1;
    for (auto to: g[v]) {
        up[to] = up[v] + 1;
        dfs(to);
        col[v] += col[to];
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    g.assign(n, {});
    up.assign(n, {});
    col.assign(n, {});
    vector<ll> x(k);
    vector<ll> p(n);
    map<ll,ll> mp;
    for (ll i = 0; i < k; i++) {
        cin >> x[i];
        mp[x[i]]++;
    }
    sort(x.begin(), x.end());
    for (ll i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].push_back(i);
    }
    ll ans = 1;
    for (ll i = 1; i <= n; i++) {
        if (mp[i] != 0)continue;
        ll col = (lower_bound(x.begin(), x.end(), i) - x.begin()) + 1;
        ans *= col;
        ans %= MOD;
    }
    cout << ans;
}
