#include <bits/stdc++.h>

// #pragma GCC optimize("Ofast")

using namespace std;

using ll = long long;
using ld = long double;

constexpr long long INF = 1e18, MOD = 998244353;

vector<bool> bl;
vector<vector<ll>> g;
vector<ll> p;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    ll n, k;
    cin >> n >> k;
    bl.resize(n, false);
    for (ll i = 0; i < k; ++i) {
        ll x;
        cin >> x;
        bl[x - 1] = true;
    }
    g.resize(n);
    p.resize(n);
    for (ll i = 0; i < n - 1; ++i) {
        ll x;
        cin >> x;
        x--;
        p[i + 1] = x;
        g[i + 1].push_back(x);
        g[x].push_back(i + 1);
    }
    ll ans = 1;
    for (ll i = n - 1; i >= 0; --i) {
        if (bl[i]) {
            k--;
            
            continue;
        }
        else {
            ans *= (k + 1);
        }
        ans %= MOD;
    }
    cout << ans;
}