#include <bits/stdc++.h>

#define int long long

using namespace std;

const int Mod = 998244353;

int binpow(int b, int p) {
    if (p == 0) return 1;
    if (p % 2 == 0) return binpow((b * b) % Mod, p / 2);
    return (binpow(b, p - 1) * b) % Mod;
}

int n, k;
vector<int> z, p, zT, zp, sz, cz;
vector<vector<int>> ch, zch, dp;

void dfst(int v, int cur = -1) {
    if (zT[v] != -1) {
        if (cur == -1) cur = zT[v];
        zp[zT[v]] = cur;
    }
    cur = zT[v];
    for (int u : ch[v]) {
        dfst(u, cur);
    }
}

void dfsz(int v) {
    sz[v] = 1;
    for (int u : ch[v]) {
        dfsz(u);
        sz[v] += sz[u];
    }
}

void dfsc(int v) {
    if (zT[v] != -1) {
        cz[v]++;
    }
    for (int u : ch[v]) {
        cz[u] = cz[v];
        dfsc(u);
    }
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> k;
    z.resize(k);
    p.resize(n);
    zT.resize(n, -1);
    zp.resize(n);
    ch.resize(n);    
    for (int i = 0; i < k; i++) {
        cin >> z[i];
        z[i]--;
        zT[z[i]] = i;
    }
    for (int i = 1; i < n; i++) {
        cin >> p[i];
        p[i]--;
        ch[p[i]].push_back(i);
    }

    dp.resize(n);
    dfst(0);

    zch.resize(n);
    for (int i = 0; i < k; i++) {
        if (zp[i] != i) {
            zch[zp[i]].push_back(i);
        }
    }

    sz.resize(n);
    dfsz(0);

    cz.resize(n);
    dfsc(0);

    int ans = 1;
    for (int i = 0; i < n; i++) {
        if (zT[i] == -1) {
            ans *= cz[i] + 1;
        }
        ans %= Mod;
    }
    cout << ans << "\n";
}
