#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int ll

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

const int inf = 2e9, INF = 1e18;
const int MAXN = 1e6 + 52, mod = 998244353;
vector<int> dp[MAXN];
vector<int> g[MAXN];
int f[MAXN];
int p[MAXN];
bool nd[MAXN];
int sz[MAXN];

int mul(int a, int b) {
    return a * b % mod;
}

int sum(int a, int b) {
    return (a + b) % mod;
    int s = a + b;
    if (s >= mod) return s - mod;
    return s;
}

void add(vector<int> &dp, vector<int> &dp0, int x, int y) {
    for (int i = dp.size() - 1; i >= x; i--) {
        dp[i] = sum(dp[i], mul(dp0[i - x], y));
    }
}

int c(int n, int k) {
    return mul(f[n], mul(p[k], p[n - k]));
}

int par[MAXN];
int ans = 1;

void dfs(int v, int cnt = 0) {
    sz[v] = 1;
    for (auto &u: g[v]) {
        dfs(u, cnt + nd[v]);
        sz[v] += sz[u];
    }
    if (!nd[v] && cnt) {
        ans = mul(ans, cnt + 1);
    }
}

int bin_pow(int a, int b) {
    int ans = 1;
    while (b) {
        if (b % 2) ans = ans * a % mod;
        b /= 2;
        a = a * a % mod;
    }
    return ans;
}

void solve() {
    int n, k;
    cin >> n >> k;
    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = mul(f[i - 1], i);
    p[n] = bin_pow(f[n], mod - 2);
    for (int i = n - 1; i >= 0; i--) p[i] = mul(p[i + 1], i + 1);
    vector<int> a;
    while (k--) {
        int x;
        cin >> x;
        a.push_back(x);
        nd[x] = true;
    }
    for (int i = 2; i <= n; i++) {
        int p;
        cin >> p;
        par[i] = p;
        g[p].push_back(i);
    }
    dfs(1);
    cout << ans;
}

int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int tt = 1;
    // cin >> tt;
    while (tt--) {
        solve();
    }
}
