#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
using ll = long long;
using ld = long double;

#define int long long
const int maxn = 1e6 + 2;
const int inf = 1e9 + 1, mod = 998244353;

int x[maxn], p[maxn];

vector<int> g[maxn];

int h[maxn], cnt[maxn];

void dfs(int v) {
    h[v] = h[p[v]];
    if (x[v]) {
        h[v]++;
    }
    cnt[v] = 1;
    for (int u : g[v]) {
        dfs(u);
        cnt[v] += cnt[u];
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k; cin >> n >> k;
    for (int i = 1; i < k + 1; i++) {
        int pos; cin >> pos;
        x[pos] = 1;
    }
    for (int i = 2; i < n + 1; i++) {
        cin >> p[i];
        g[p[i]].push_back(i);
    }
    dfs(1);
    int res = 1;
    for (int i = 1; i < n + 1; i++) {
        if (x[i]) {
            continue;
        }
        res = res * (h[i] + 1) % mod;
    }
    cout << res << "\n";
}
