#include <bits/stdc++.h>
#pragma optimize("Ofast")
#pragma optimize("O3")

using namespace std;

using ll = long long;

const int INF = 1e9 + 7, mod = 998244353;

#ifdef LOCAL
const int MAXN = 1e2, MAXK = 2001;
#else
const int MAXN = 1e6, MAXK = 2001;
#endif

int n, k;
vector<int> fv, sm, h;
vector<vector<int>> g, c(MAXK, vector<int>(MAXK, 1));
ll ans = 1, cnt = 0;

void dfs(int u) {
    if (fv[u]) {
        cnt++;
    } else {
        ans *= (cnt + 1);
        ans %= mod;
    }
    if (g.size())
        dfs(g[u][0]);
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k;
    fv.resize(n);
    sm.resize(n);
    g.resize(n);
    // dp.resize(n);
    for (int i = 0; i < k; i++) {
        int v;
        cin >> v;
        v--;
        fv[v] = 1;
    }
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }
    // for (int i = 0; i < MAXK; i++) {
    //     c[i][0] = 1;
    //     c[i][i] = 1;
    //     for (int j = 1; j < i; j++)
    //         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    // }
    dfs(0);
    cout << ans;
    return 0;
}