#include <iostream>
#include <vector>

using namespace std;

const int MOD = 998244353;
vector <vector <int>> gr;
vector <int> sz;

int deg(int a, int b) {
    if (b == 0) {
        return 1;
    }
    if (b == 1) {
        return a;
    }
    if (b % 2 == 0) {
        int c = deg(a, b / 2);
        return (c * 1ll * c) % MOD;
    }
    int c = deg(a, b - 1);
    return (c * 1ll * a) % MOD;
}

void dfs(int v) {
    sz[v] = 1;
    for (int nv : gr[v]) {
        dfs(nv);
        sz[v] += sz[nv];
    }
}

int main() {
    int n, k;
    cin >> n >> k;
    int x[k], p[n + 1];
    bool bam = true;
    for (int i = 0; i < k; ++i) {
        cin >> x[i];
    }
    for (int i = 2; i <= n; ++i) {
        cin >> p[i];
        if (p[i] != i - 1) {
            bam = false;
        }
    }
    if (bam) {
        int var[n + 1];
        for (int i = 0; i <= n; ++i) {
            var[i] = 0;
        }
        for (int i = 0; i < k; ++i) {
            var[x[i]] = 1;
        }
        for (int i = 1; i <= n; ++i) {
            var[i] += var[i - 1];
        }
        for (int i = 0; i < k; ++i) {
            var[x[i]] = 0;
        }
        int ans = 1;
        for (int i = 1; i <= n; ++i) {
            ans = (ans * 1ll * (var[i] + 1)) % MOD;
        }
        cout << ans;
    } else if (k == 1) {
        gr.assign(n + 1, vector <int> ());
        sz.assign(n + 1, 0);
        for (int i = 2; i <= n; ++i) {
            gr[p[i]].push_back(i);
        }
        dfs(1);
        int ans = deg(2, sz[x[0]] - 1), res = 1;
        for (int nv : gr[x[0]]) {
            res = (res * 1ll * deg(2, sz[nv])) % MOD;
        }
        ans += res - 1;
        if (ans < 0) {
            ans += MOD;
        }
        if (ans >= MOD) {
            ans -= MOD;
        }
        for (int nv : gr[x[0]]) {
            ans -= deg(2, sz[nv]) - 1;
            if (ans < 0) {
                ans += MOD;
            }
        }
        cout << ans;
    }
    return 0;
}
