#include <bits/stdc++.h>

#define int long long

using ll = long long;
using ld = long double;
using namespace std;
mt19937 rnd(239);

const int mod = 998244353;

int bpow(int x, int n) {
    if (!n) return 1;
    int u = bpow(x, n / 2);
    return u * u % mod * (n % 2 ? x : 1) % mod;
}

int dfs3(int v, vector <int> &a,  vector <int> &sz, vector <vector <int>> &g) {
    sz[v] = 1;
    int otv = 0;
    for (auto u : g[v]) {
        otv += dfs3(u, a, sz, g);
        sz[v] += sz[u];
    }
    if (a[v]) {
        otv = bpow(2, sz[v] - 1);
        int sum = 0, nw = 0;
        for (auto u : g[v]) {
            nw = (nw + sz[u] * sum) % mod;
            sum += sz[u];
        }
        otv = (otv + nw * bpow(2, sz[v] - 3)) % mod;
    }
    return otv;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, m, x, ok4 = 1; cin >> n >> m;
    vector <int> p(n, -1), a(n, 0);
    for (int i = 0; i < m; i++) {
        cin >> x;
        a[--x] = 1;
    }
    for (int i = 1; i < n; i++) {
        cin >> p[i]; p[i]--;
        if (p[i] != i - 1) ok4 = 0;
    }
    if (ok4) {
        vector <int> pref(n);
        pref[0] = a[0];
        for (int i = 1; i < n; i++) pref[i] = pref[i - 1] + a[i];
        int otv = 1;
        for (int i = 0; i < n; i++) {
            if (a[i]) continue;
            otv = (otv * (pref[i] + 1)) % mod;
        }
        cout << otv << "\n";
        return 0;
    }
    vector <vector <int>> g(n);
    for (int i = 1; i < n; i++) g[p[i]].push_back(i);
    vector <int> sz(n);
    cout << dfs3(0, a, sz, g) << "\n";
    return 0;
}
